Re: [FFmpeg-devel] [PATCH] avformat/mov: fix eof check after avio_skip()

2025-02-02 Thread Kacper Michajlow
On Mon, 3 Feb 2025 at 06:24, Kacper Michajłow  wrote:
>
> This fix ensures that the loop stops early on EOF. The issue occurs
> because mov_read_infe() performs a version check and skips unsupported
> versions. The problem is that seeking within the stream clears the EOF
> flag, causing avio_feof() to not function as expected. This is resolved
> by moving the EOF check after reading the size and type after seek,
> ensuring the EOF flag is set when necessary.
>
> Signed-off-by: Kacper Michajłow 
> ---
>  libavformat/mov.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 2c8be51063..9a388bf723 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -8868,12 +8868,12 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  for (i = 0; i < entry_count; i++) {
>  MOVAtom infe;
>
> +infe.size = avio_rb32(pb) - 8;
> +infe.type = avio_rl32(pb);
>  if (avio_feof(pb)) {
>  ret = AVERROR_INVALIDDATA;
>  goto fail;
>  }
> -infe.size = avio_rb32(pb) - 8;
> -infe.type = avio_rl32(pb);
>  ret = mov_read_infe(c, pb, infe, i);
>  if (ret < 0)
>  goto fail;
> --
> 2.45.1
>

Sorry, sent the wrong patch, consider v2, with commit title fix.

- Kacper
___
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/mov: fix eof check after avio_skip()

2025-02-02 Thread Kacper Michajłow
This fix ensures that the loop stops early on EOF. The issue occurs
because mov_read_infe() performs a version check and skips unsupported
versions. The problem is that seeking within the stream clears the EOF
flag, causing avio_feof() to not function as expected. This is resolved
by moving the EOF check after reading the size and type after seek,
ensuring the EOF flag is set when necessary.

Signed-off-by: Kacper Michajłow 
---
 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2c8be51063..9a388bf723 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8868,12 +8868,12 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 for (i = 0; i < entry_count; i++) {
 MOVAtom infe;
 
+infe.size = avio_rb32(pb) - 8;
+infe.type = avio_rl32(pb);
 if (avio_feof(pb)) {
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-infe.size = avio_rb32(pb) - 8;
-infe.type = avio_rl32(pb);
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
 goto fail;
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH v2] avformat/mov: fix eof check in mov_read_iinf()

2025-02-02 Thread Kacper Michajłow
This fix ensures that the loop stops early on EOF. The issue occurs
because mov_read_infe() performs a version check and skips unsupported
versions. The problem is that seeking within the stream clears the EOF
flag, causing avio_feof() to not function as expected. This is resolved
by moving the EOF check after reading the size and type, ensuring the
EOF flag is set when necessary.

Signed-off-by: Kacper Michajłow 
---
 libavformat/mov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2c8be51063..9a388bf723 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8868,12 +8868,12 @@ static int mov_read_iinf(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 for (i = 0; i < entry_count; i++) {
 MOVAtom infe;
 
+infe.size = avio_rb32(pb) - 8;
+infe.type = avio_rl32(pb);
 if (avio_feof(pb)) {
 ret = AVERROR_INVALIDDATA;
 goto fail;
 }
-infe.size = avio_rb32(pb) - 8;
-infe.type = avio_rl32(pb);
 ret = mov_read_infe(c, pb, infe, i);
 if (ret < 0)
 goto fail;
-- 
2.45.1

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

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


[FFmpeg-devel] [PATCH] doc/filters: Add CUDA Video Filters section for CUDA-based and CUDA+NPP based filters.

2025-02-02 Thread Danil Iashchenko
---
 doc/filters.texi | 1323 --
 1 file changed, 700 insertions(+), 623 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index c2817b2661..7460b7ef18 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8619,45 +8619,6 @@ Set planes to filter. Default is first only.
 
 This filter supports the all above options as @ref{commands}.
 
-@section bilateral_cuda
-CUDA accelerated bilateral filter, an edge preserving filter.
-This filter is mathematically accurate thanks to the use of GPU acceleration.
-For best output quality, use one to one chroma subsampling, i.e. yuv444p 
format.
-
-The filter accepts the following options:
-@table @option
-@item sigmaS
-Set sigma of gaussian function to calculate spatial weight, also called sigma 
space.
-Allowed range is 0.1 to 512. Default is 0.1.
-
-@item sigmaR
-Set sigma of gaussian function to calculate color range weight, also called 
sigma color.
-Allowed range is 0.1 to 512. Default is 0.1.
-
-@item window_size
-Set window size of the bilateral function to determine the number of 
neighbours to loop on.
-If the number entered is even, one will be added automatically.
-Allowed range is 1 to 255. Default is 1.
-@end table
-@subsection Examples
-
-@itemize
-@item
-Apply the bilateral filter on a video.
-
-@example
-./ffmpeg -v verbose \
--hwaccel cuda -hwaccel_output_format cuda -i input.mp4  \
--init_hw_device cuda \
--filter_complex \
-" \
-[0:v]scale_cuda=format=yuv444p[scaled_video];
-[scaled_video]bilateral_cuda=window_size=9:sigmaS=3.0:sigmaR=50.0" \
--an -sn -c:v h264_nvenc -cq 20 out.mp4
-@end example
-
-@end itemize
-
 @section bitplanenoise
 
 Show and measure bit plane noise.
@@ -9243,58 +9204,6 @@ Only deinterlace frames marked as interlaced.
 The default value is @code{all}.
 @end table
 
-@section bwdif_cuda
-
-Deinterlace the input video using the @ref{bwdif} algorithm, but implemented
-in CUDA so that it can work as part of a GPU accelerated pipeline with nvdec
-and/or nvenc.
-
-It accepts the following parameters:
-
-@table @option
-@item mode
-The interlacing mode to adopt. It accepts one of the following values:
-
-@table @option
-@item 0, send_frame
-Output one frame for each frame.
-@item 1, send_field
-Output one frame for each field.
-@end table
-
-The default value is @code{send_field}.
-
-@item parity
-The picture field parity assumed for the input interlaced video. It accepts one
-of the following values:
-
-@table @option
-@item 0, tff
-Assume the top field is first.
-@item 1, bff
-Assume the bottom field is first.
-@item -1, auto
-Enable automatic detection of field parity.
-@end table
-
-The default value is @code{auto}.
-If the interlacing is unknown or the decoder does not export this information,
-top field first will be assumed.
-
-@item deint
-Specify which frames to deinterlace. Accepts one of the following
-values:
-
-@table @option
-@item 0, all
-Deinterlace all frames.
-@item 1, interlaced
-Only deinterlace frames marked as interlaced.
-@end table
-
-The default value is @code{all}.
-@end table
-
 @section ccrepack
 
 Repack CEA-708 closed captioning side data
@@ -9408,48 +9317,6 @@ ffmpeg -f lavfi -i color=c=black:s=1280x720 -i video.mp4 
-shortest -filter_compl
 @end example
 @end itemize
 
-@section chromakey_cuda
-CUDA accelerated YUV colorspace color/chroma keying.
-
-This filter works like normal chromakey filter but operates on CUDA frames.
-for more details and parameters see @ref{chromakey}.
-
-@subsection Examples
-
-@itemize
-@item
-Make all the green pixels in the input video transparent and use it as an 
overlay for another video:
-
-@example
-./ffmpeg \
--hwaccel cuda -hwaccel_output_format cuda -i input_green.mp4  \
--hwaccel cuda -hwaccel_output_format cuda -i base_video.mp4 \
--init_hw_device cuda \
--filter_complex \
-" \
-[0:v]chromakey_cuda=0x25302D:0.1:0.12:1[overlay_video]; \
-[1:v]scale_cuda=format=yuv420p[base]; \
-[base][overlay_video]overlay_cuda" \
--an -sn -c:v h264_nvenc -cq 20 output.mp4
-@end example
-
-@item
-Process two software sources, explicitly uploading the frames:
-
-@example
-./ffmpeg -init_hw_device cuda=cuda -filter_hw_device cuda \
--f lavfi -i color=size=800x600:color=white,format=yuv420p \
--f lavfi -i yuvtestsrc=size=200x200,format=yuv420p \
--filter_complex \
-" \
-[0]hwupload[under]; \
-[1]hwupload,chromakey_cuda=green:0.1:0.12[over]; \
-[under][over]overlay_cuda" \
--c:v hevc_nvenc -cq 18 -preset slow output.mp4
-@end example
-
-@end itemize
-
 @section chromanr
 Reduce chrominance noise.
 
@@ -10427,38 +10294,6 @@ For example to convert the input to SMPTE-240M, use 
the command:
 colorspace=smpte240m
 @end example
 
-@section colorspace_cuda
-
-CUDA accelerated implementation of the colorspace filter.
-
-It is by no means feature complete compared to the software colorspace filter,
-and at the current time only supports color range

Re: [FFmpeg-devel] libswresample/rematrix.c sane_layout

2025-02-02 Thread James Almer

On 1/30/2025 12:29 AM, Pavel Koshevoy wrote:

Hi,

I have a file which I can't down-mix to stereo due to
AV_CHANNEL_ORDER_NATIVE requirement in sane_layout.


Can you share that file? Or any other that reproduces this?



```
$ ffmpeg -i COMMUNITY_HERO_2.mov -vn -af
'aformat=sample_rates=48000:channel_layouts=stereo' -y /tmp/out.wav
ffmpeg version N-118381-g4ba9ae7742 Copyright (c) 2000-2025 the FFmpeg
developers
   built with gcc 7 (SUSE Linux)
   configuration: --prefix=/Developer/x86_64 --prefix=/Developer/x86_64
--enable-runtime-cpudetect --enable-libzimg --enable-libx264
--enable-libass --enable-libmodplug --enable-libxml2 --enable-libvmaf
--enable-shared --enable-pthreads --enable-gpl --enable-version3
--enable-gnutls --enable-libfreetype --enable-pic --disable-static
--enable-shared --enable-rpath --enable-ffnvcodec --enable-debug
--disable-stripping --disable-optimizations --disable-mmx
   libavutil  59. 56.100 / 59. 56.100
   libavcodec 61. 31.101 / 61. 31.101
   libavformat61.  9.106 / 61.  9.106
   libavdevice61.  4.100 / 61.  4.100
   libavfilter10.  9.100 / 10.  9.100
   libswscale  8. 13.100 /  8. 13.100
   libswresample   5.  4.100 /  5.  4.100
   libpostproc58.  4.100 / 58.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'COMMUNITY_HERO_2.mov':
   Metadata:
 major_brand : qt
 minor_version   : 512
 compatible_brands: qt
 encoder : Lavf58.29.100
   Duration: 00:02:02.86, start: 0.00, bitrate: 97805 kb/s
   Stream #0:0[0x1]: Video: prores (LT) (apcs / 0x73637061), yuv422p10le(top
first), 1920x1080, 88583 kb/s, SAR 1:1 DAR 16:9, 29.97 fps, 29.97 tbr, 30k
tbn (default)
 Metadata:
   handler_name: VideoHandler
   vendor_id   : FFMP
   encoder : Lavc58.54.100 prores
   timecode: 14:25:46;28
   Stream #0:1[0x2]: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 8
channels (FL+FR+FC+LFE+SL+SR+BL+BR), s32 (24 bit), 9216 kb/s (default)
 Metadata:
   handler_name: SoundHandler
   vendor_id   : [0][0][0][0]
   Stream #0:2[0x3](eng): Data: none (tmcd / 0x64636D74)
 Metadata:
   handler_name: TimeCodeHandler
   timecode: 14:25:46;28
Stream mapping:
   Stream #0:1 -> #0:0 (pcm_s24le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[auto_aresample_0 @ 0x7ff5bc004900] [SWR @ 0x7ff5bc0049f0] Input channel
layout '8 channels (FL+FR+FC+LFE+SL+SR+BL+BR)' is not supported
[auto_aresample_0 @ 0x7ff5bc004900] Failed to configure output pad on
auto_aresample_0
[af#0:0 @ 0x21841830] Error reinitializing filters!
[af#0:0 @ 0x21841830] Task finished with error code: -22 (Invalid argument)
[af#0:0 @ 0x21841830] Terminating thread with return code -22 (Invalid
argument)
[aost#0:0/pcm_s16le @ 0x218412b0] [enc:pcm_s16le @ 0x21841770] Could not
open encoder before EOF
[aost#0:0/pcm_s16le @ 0x218412b0] Task finished with error code: -22
(Invalid argument)
[aost#0:0/pcm_s16le @ 0x218412b0] Terminating thread with return code -22
(Invalid argument)
[out#0/wav @ 0x21840b80] Nothing was written into output file, because at
least one of its streams received no packets.
size=   0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!
```

If I remove 2 lines from sane_layout then I am able to process this file
successfully.
However IDK the implications of this change.


swr will attempt to handle things it doesn't understand, like ambisonics 
or channels in arbitrary positions, potentially crashing.




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] avfilter/xpsnr: avoid division by zero

2025-02-02 Thread Gyan Doshi
The ref input may have its frame rate unset, which would then lead to
SIGFPE. So fall back to the main link frame rate. If that too is unset,
default to 0.

Related to #11428
---
 libavfilter/vf_xpsnr.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c
index 1b2c2a7c2c..3097db0878 100644
--- a/libavfilter/vf_xpsnr.c
+++ b/libavfilter/vf_xpsnr.c
@@ -552,6 +552,7 @@ static int config_input_ref(AVFilterLink *inlink)
 AVFilterContext  *ctx = inlink->dst;
 XPSNRContext *const s = ctx->priv;
 FilterLink *il = ff_filter_link(inlink);
+FilterLink *ml = ff_filter_link(ctx->inputs[0]);
 
 if ((ctx->inputs[0]->w != ctx->inputs[1]->w) ||
 (ctx->inputs[0]->h != ctx->inputs[1]->h)) {
@@ -568,7 +569,9 @@ static int config_input_ref(AVFilterLink *inlink)
 s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */
 s->max_error_64 *= s->max_error_64;
 
-s->frame_rate = il->frame_rate.num / il->frame_rate.den;
+// Avoid division by zero
+s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / 
il->frame_rate.den) :
+ml->frame_rate.den ? (ml->frame_rate.num / 
ml->frame_rate.den) : 0;
 
 s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components);
 
-- 
2.46.1

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

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


Re: [FFmpeg-devel] Democratization work in progress draft v2

2025-02-02 Thread James Almer

On 2/1/2025 6:53 PM, Michael Niedermayer wrote:

Hi James

On Sat, Feb 01, 2025 at 10:30:21AM -0300, James Almer wrote:

On 1/31/2025 9:49 PM, Michael Niedermayer wrote:

Hi James

On Fri, Jan 31, 2025 at 12:44:50PM -0300, James Almer wrote:

On 1/31/2025 11:58 AM, Nicolas George wrote:

Niklas Haas (12025-01-30):

[...]

On the other hand, I believe this whole plan is a bad idea.

Yes, it is a bad idea. We have had the current system in place for about
five years now, and besides one or two CC assemblages being inefficient, it


Do you remember this suggested addition to the FAQ ?
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2025-January/338186.html

It seems you dont remember it even though this was posted just a few days ago
I knew this is needed to be put in the FAQ ;(


I saw it, and i think that patch is anything but objective and completely
unacceptable. You're stating your opinion and discrediting a system in an
official document in the project's repository itself of all places. Do you
not see how absurd that is?


The system is absurd


The system is fine. One CC was inefficient and it bothered you to the 
point you want to start everything from scratch. It's not reasonable.


, the text points this out in a mocking/ironic way.

If you want me to reword this in a dry formal way, i can submit such a patch?

If not, how do you suggest we move forward here ?
We can replace the GA by a system that is not vulnerable


I ask again, do you have any reason other than an hypothetical scenario 
to think the GA is vulnerable? Or can you mention a point during the 
last five years where any such a vulnerability was taken advantage of?


Shit happened with xz, and now every contributor in FOSS is a suspect? 
You handle the releases, including git tags and tarballs. There's no way 
something like that could happen here. And unlike the people that 
infiltrated that project, everyone here who's active and has access to 
some part of the infrastructure has a very public presence online and 
most even offline in plenty of events and conventions. Not to mention, 
nothing the GA could vote for would even remotely result in someone 
being able to do something like the xz tarball hijack.


If commit access is something you worry about, once we move to 
Gitlab/Forgejo, we can limit the people with MR merging permissions to 
strictly only those in Maintainers. And release/tagging can be further 
limited to only you, to keep things as is.



We can treat the GA more as guidance and not a final authority


This is trying to declare that an agreed upon system in place will no 
longer be valid because you're not satisfied with how one part of it 
behaved. And if the GA becomes guidance, who or what will be the final 
authority? If it turns out to be a "who", then we'd not be dealing with 
a community managed project anymore.




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] libavcodec/mpeg12dec.c: rename 0x0502 CC format

2025-02-02 Thread Scott Theisen
The format is used by at least Dish Network, but is not defined in any DVB
standard, so remove references to DVB.

This is a simple rename, no functional change.
---
 libavcodec/mpeg12dec.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 9bb995b5be..0002f016e9 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -67,7 +67,7 @@ enum Mpeg2ClosedCaptionsFormat {
 CC_FORMAT_A53_PART4,
 CC_FORMAT_SCTE20,
 CC_FORMAT_DVD,
-CC_FORMAT_DVB_0502
+CC_FORMAT_DISH
 };
 
 typedef struct Mpeg1Context {
@@ -2064,39 +2064,39 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 mpeg_set_cc_format(avctx, CC_FORMAT_DVD, "DVD");
 }
 return 1;
-} else if ((!s1->cc_format || s1->cc_format == CC_FORMAT_DVB_0502) &&
+} else if ((!s1->cc_format || s1->cc_format == CC_FORMAT_DISH) &&
buf_size >= 12 &&
p[0] == 0x05 && p[1] == 0x02) {
-/* extract DVB 0502 CC data */
+/* extract Dish Network CC data */
 const uint8_t cc_header = 0xf8 | 0x04 /* valid */ | 0x00 /* line 21 
field 1 */;
 uint8_t cc_data[4] = {0};
 int cc_count = 0;
-uint8_t dvb_cc_type = p[7];
+uint8_t cc_type = p[7];
 p += 8;
 buf_size -= 8;
 
-if (dvb_cc_type == 0x05 && buf_size >= 7) {
-dvb_cc_type = p[6];
+if (cc_type == 0x05 && buf_size >= 7) {
+cc_type = p[6];
 p += 7;
 buf_size -= 7;
 }
 
-if (dvb_cc_type == 0x02 && buf_size >= 4) { /* 2-byte caption, can be 
repeated */
+if (cc_type == 0x02 && buf_size >= 4) { /* 2-byte caption, can be 
repeated */
 cc_count = 1;
 cc_data[0] = p[1];
 cc_data[1] = p[2];
-dvb_cc_type = p[3];
+cc_type = p[3];
 
 /* Only repeat characters when the next type flag
  * is 0x04 and the characters are repeatable (i.e., less than
  * 32 with the parity stripped).
  */
-if (dvb_cc_type == 0x04 && (cc_data[0] & 0x7f) < 32) {
+if (cc_type == 0x04 && (cc_data[0] & 0x7f) < 32) {
 cc_count = 2;
 cc_data[2] = cc_data[0];
 cc_data[3] = cc_data[1];
 }
-} else if (dvb_cc_type == 0x04 && buf_size >= 5) { /* 4-byte caption, 
not repeated */
+} else if (cc_type == 0x04 && buf_size >= 5) { /* 4-byte caption, not 
repeated */
 cc_count = 2;
 cc_data[0] = p[1];
 cc_data[1] = p[2];
@@ -2124,7 +2124,7 @@ static int mpeg_decode_a53_cc(AVCodecContext *avctx,
 }
 }
 
-mpeg_set_cc_format(avctx, CC_FORMAT_DVB_0502, "DVB 0502");
+mpeg_set_cc_format(avctx, CC_FORMAT_DISH, "Dish Network");
 }
 return 1;
 }
@@ -2687,7 +2687,7 @@ const FFCodec ff_mpeg1video_decoder = {
 static const AVOption mpeg2video_options[] = {
 { "cc_format", "extract a specific Closed Captions format",
M2V_OFFSET(cc_format), AV_OPT_TYPE_INT, { .i64 = CC_FORMAT_AUTO },
-CC_FORMAT_AUTO, CC_FORMAT_DVB_0502, M2V_PARAM, .unit = "cc_format" },
+CC_FORMAT_AUTO, CC_FORMAT_DISH, M2V_PARAM, .unit = "cc_format" },
 
{ "auto",   "pick first seen CC substream",  0, AV_OPT_TYPE_CONST,
 { .i64 =   CC_FORMAT_AUTO },.flags = M2V_PARAM, .unit 
= "cc_format" },
@@ -2697,8 +2697,8 @@ static const AVOption mpeg2video_options[] = {
 { .i64 =   CC_FORMAT_SCTE20 },  .flags = M2V_PARAM, .unit 
= "cc_format" },
{ "dvd","pick DVD CC substream", 0, AV_OPT_TYPE_CONST,
 { .i64 =   CC_FORMAT_DVD }, .flags = M2V_PARAM, .unit 
= "cc_format" },
-   { "dvb_0502", "pick DVB 0502 CC substream",  0, AV_OPT_TYPE_CONST,
-{ .i64 =   CC_FORMAT_DVB_0502 },.flags = M2V_PARAM, .unit 
= "cc_format" },
+   { "dish",   "pick Dish Network CC substream", 0, AV_OPT_TYPE_CONST,
+{ .i64 =   CC_FORMAT_DISH },.flags = M2V_PARAM, .unit 
= "cc_format" },
 { NULL }
 };
 
-- 
2.43.0

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

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


[FFmpeg-devel] [PATCH] avformat/mov: add an offset to IAMF streams

2025-02-02 Thread James Almer
Using audio_substream_id for AVStream ids is not ideal give that in containers
like mp4, the IAMF structure is opaque to the outside and other streams may
share such id values.

Signed-off-by: James Almer 
---
 libavformat/iamf_reader.c| 12 +++---
 libavformat/iamf_reader.h|  2 +-
 libavformat/iamfdec.c|  2 +-
 libavformat/isom.h   |  1 +
 libavformat/mov.c| 29 +-
 tests/ref/fate/mov-mp4-iamf-7_1_4-video-last | 42 ++--
 6 files changed, 58 insertions(+), 30 deletions(-)

diff --git a/libavformat/iamf_reader.c b/libavformat/iamf_reader.c
index d331e1315e..5cbe89ca68 100644
--- a/libavformat/iamf_reader.c
+++ b/libavformat/iamf_reader.c
@@ -31,10 +31,10 @@
 #include "iamf_parse.h"
 #include "iamf_reader.h"
 
-static AVStream *find_stream_by_id(AVFormatContext *s, int id)
+static AVStream *find_stream_by_id(AVFormatContext *s, int id, int 
stream_id_offset)
 {
 for (int i = 0; i < s->nb_streams; i++)
-if (s->streams[i]->id == id)
+if (s->streams[i]->id == id + stream_id_offset)
 return s->streams[i];
 
 av_log(s, AV_LOG_ERROR, "Invalid stream id %d\n", id);
@@ -45,7 +45,7 @@ static int audio_frame_obu(AVFormatContext *s, const 
IAMFDemuxContext *c,
AVIOContext *pb, AVPacket *pkt,
int len, enum IAMF_OBU_Type type,
unsigned skip_samples, unsigned discard_padding,
-   int id_in_bitstream)
+   int stream_id_offset, int id_in_bitstream)
 {
 AVStream *st;
 int ret, audio_substream_id;
@@ -59,7 +59,7 @@ static int audio_frame_obu(AVFormatContext *s, const 
IAMFDemuxContext *c,
 } else
 audio_substream_id = type - IAMF_OBU_IA_AUDIO_FRAME_ID0;
 
-st = find_stream_by_id(s, audio_substream_id);
+st = find_stream_by_id(s, audio_substream_id, stream_id_offset);
 if (!st)
 return AVERROR_INVALIDDATA;
 
@@ -277,7 +277,7 @@ fail:
 }
 
 int ff_iamf_read_packet(AVFormatContext *s, IAMFDemuxContext *c,
-AVIOContext *pb, int max_size, AVPacket *pkt)
+AVIOContext *pb, int max_size, int stream_id_offset, 
AVPacket *pkt)
 {
 int read = 0;
 
@@ -308,7 +308,7 @@ int ff_iamf_read_packet(AVFormatContext *s, 
IAMFDemuxContext *c,
 read += len;
 if (type >= IAMF_OBU_IA_AUDIO_FRAME && type <= 
IAMF_OBU_IA_AUDIO_FRAME_ID17) {
 ret = audio_frame_obu(s, c, pb, pkt, obu_size, type,
-   skip_samples, discard_padding,
+   skip_samples, discard_padding, 
stream_id_offset,
type == IAMF_OBU_IA_AUDIO_FRAME);
 if (ret < 0)
 return ret;
diff --git a/libavformat/iamf_reader.h b/libavformat/iamf_reader.h
index ecb92d485a..279739cde9 100644
--- a/libavformat/iamf_reader.h
+++ b/libavformat/iamf_reader.h
@@ -42,7 +42,7 @@ typedef struct IAMFDemuxContext {
 } IAMFDemuxContext;
 
 int ff_iamf_read_packet(AVFormatContext *s, IAMFDemuxContext *c,
-AVIOContext *pb, int max_size, AVPacket *pkt);
+AVIOContext *pb, int max_size, int stream_id_offset, 
AVPacket *pkt);
 
 void ff_iamf_read_deinit(IAMFDemuxContext *c);
 
diff --git a/libavformat/iamfdec.c b/libavformat/iamfdec.c
index e1a913dd1c..0f273bdd43 100644
--- a/libavformat/iamfdec.c
+++ b/libavformat/iamfdec.c
@@ -187,7 +187,7 @@ static int iamf_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 IAMFDemuxContext *const c = s->priv_data;
 int ret;
 
-ret = ff_iamf_read_packet(s, c, s->pb, INT_MAX, pkt);
+ret = ff_iamf_read_packet(s, c, s->pb, INT_MAX, 0, pkt);
 if (ret < 0)
 return ret;
 
diff --git a/libavformat/isom.h b/libavformat/isom.h
index ccdead7192..10f882806e 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -283,6 +283,7 @@ typedef struct MOVStreamContext {
 } cenc;
 
 struct IAMFDemuxContext *iamf;
+int iamf_stream_offset;
 } MOVStreamContext;
 
 typedef struct HEIFItem {
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2c8be51063..168a4332cb 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -10426,6 +10426,30 @@ static int mov_parse_lcevc_streams(AVFormatContext *s)
 return 0;
 }
 
+static void fix_stream_ids(AVFormatContext *s)
+{
+int highest_id = 0;
+
+for (int i = 0; i < s->nb_streams; i++) {
+const AVStream *st = s->streams[i];
+const MOVStreamContext *sc = st->priv_data;
+if (!sc->iamf)
+highest_id = FFMAX(highest_id, st->id);
+}
+highest_id += !highest_id;
+for (int i = 0; highest_id > 1 && i < s->nb_stream_groups; i++) {
+AVStreamGroup *stg = s->stream_groups[i];
+if (stg->type != AV_STREAM_GROUP_PARAMS_IAMF_AUDIO_ELEMENT)
+continue;
+  

Re: [FFmpeg-devel] [PATCH 0/9] Nvidia Video Codec SDK 13.0 support

2025-02-02 Thread Timo Rothenpieler

On 01.02.2025 22:15, Timo Rothenpieler wrote:

On 30.01.2025 20:40, Timo Rothenpieler wrote:

This series adds support for new features and capabilities added in
todays release of the Video Codec SDK 13.0.

Diego de Souza (7):
   avutil/hwcontext_cuda: add 4:2:2 pixel format support
   avcodec/nvdec: add 4:2:2 decoding and 10-bit support
   avcodec/cuviddec: add HEVC/H.264 4:2:2 and H.264 10-bit support
   avcodec/nvenc: add 4:2:2 encoding and H.264 10-bit support
   avcodec/nvenc: add UHQ to AV1 for NVENC
   avcodec/nvenc: add Temporal Filtering for AV1 and H.264 in NVENC
   avcodec/nvenc: add MV-HEVC encoding support

Timo Rothenpieler (2):
   avcodec/nvenc: use encoder level options for qmin/qmax
   avcodec/nvenc: finalize SDK 13.0 support


Will push this series minus the MV-HEVC patch tomorrow if nobody objects.


applied
___
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/vvc/refs: Check content_ref in set_pict_type()

2025-02-02 Thread Michael Niedermayer
Fixes: 
390565846/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4990028521996288
Fixes: Null pointer dereference

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

diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 486515d06db..1cfca482047 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -186,7 +186,7 @@ static void set_pict_type(AVFrame *frame, const VVCContext 
*s, const VVCFrameCon
 const CodedBitstreamFragment *current = &s->current_frame;
 for (int i = 0; i < current->nb_units && !has_b; i++) {
 const CodedBitstreamUnit *unit = current->units + i;
-if (unit->type <= VVC_RSV_IRAP_11) {
+if (unit->content_ref && unit->type <= VVC_RSV_IRAP_11) {
 const H266RawSliceHeader *rsh = unit->content_ref;
 has_inter |= !IS_I(rsh);
 has_b |= IS_B(rsh);
-- 
2.48.1

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

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


[FFmpeg-devel] [PATCH 1/2] avcodec/vvc/refs: fix negative pps_scaling_win offsets

2025-02-02 Thread Michael Niedermayer
The spec seems to allow these to  be negative

Fixes: left shift of negative value -15
Fixes: 
392687035/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-6559804532785152

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/vvc/refs.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vvc/refs.c b/libavcodec/vvc/refs.c
index 8d4b7bb35b2..486515d06db 100644
--- a/libavcodec/vvc/refs.c
+++ b/libavcodec/vvc/refs.c
@@ -147,10 +147,10 @@ static VVCFrame *alloc_frame(VVCContext *s, 
VVCFrameContext *fc)
 for (int j = 0; j < frame->ctb_count; j++)
 frame->rpl_tab[j] = frame->rpl;
 
-win->left_offset   = pps->r->pps_scaling_win_left_offset   << 
sps->hshift[CHROMA];
-win->right_offset  = pps->r->pps_scaling_win_right_offset  << 
sps->hshift[CHROMA];
-win->top_offset= pps->r->pps_scaling_win_top_offset<< 
sps->vshift[CHROMA];
-win->bottom_offset = pps->r->pps_scaling_win_bottom_offset << 
sps->vshift[CHROMA];
+win->left_offset   = pps->r->pps_scaling_win_left_offset   * (1 << 
sps->hshift[CHROMA]);
+win->right_offset  = pps->r->pps_scaling_win_right_offset  * (1 << 
sps->hshift[CHROMA]);
+win->top_offset= pps->r->pps_scaling_win_top_offset* (1 << 
sps->vshift[CHROMA]);
+win->bottom_offset = pps->r->pps_scaling_win_bottom_offset * (1 << 
sps->vshift[CHROMA]);
 frame->ref_width   = pps->r->pps_pic_width_in_luma_samples  - 
win->left_offset   - win->right_offset;
 frame->ref_height  = pps->r->pps_pic_height_in_luma_samples - 
win->bottom_offset - win->top_offset;
 
-- 
2.48.1

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

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


Re: [FFmpeg-devel] Democratization work in progress draft v2

2025-02-02 Thread James Almer

On 2/1/2025 7:27 PM, Michael Niedermayer wrote:

Hi James

On Sat, Feb 01, 2025 at 10:30:21AM -0300, James Almer wrote:

On 1/31/2025 9:49 PM, Michael Niedermayer wrote:

[...]




has worked. Changing it now because one person was unhappy with a CC (That


This is a false statement. Iam not suggesting a change to the GA because of one 
CC
iam suggesting a change because it is vulnerable to an attack.

(The CC isnt even fixed by this, i think the concept of a CC elected out of a
community thats full of mutual hate is a bad idea)

But back to the topic, what do you suggest to fix the vulerability in the GA ?
Or you dont care?


Why do you say there's a vulnerability in the GA?


The FAQ describes how to exploit it. And i belive others independantly found
this issue as well.



Has it been exploited for


Given the nature of this vulerability, its very hard to detect it being 
exploited



this to be an issue?


While active eploitation, certainly makes an issue worse. In general and
especially when exploitation is not detectable, this is something we cannot 
wait for



Did someone to your knowledge buy a developer to write
20 commits and get them into the GA?


Lets be carefull here with the words. But the awnser is "yes"
Many developers have been paid to write commits. employees, contractors, 
students

Do i know of someone being asked after that to vote in a specific way ?
No, how could i know other peoples private communication

Have people asked me how/if they should vote ?
Yes, some people did ask.

In general "few time" outside contributors being payed to do some work dont
care about the votes, they come, do some work and leave.
I would expect the random subscriber of 2000 on ffmpeg-devel to care more
as they follow the list for a long term they care more about the consequences


But what are the chances they'd get into the GA? Few-times outside 
contributors rarely submit more than a couple patches to implement the 
work they were paid for to do. Hardly 20 commits.
And we could always stop asking people to split their patches into 
several different smaller patches (cosmetics, refactoring, etc) to 
reduce the chances of one time contributors from meeting the GA 
requirements.


Looking at the current GA, do you see anyone in it who wrote code for 
their employer, met the requirements, and stopped being active after 
their work was upstreamed?






Otherwise, you're making a big deal out
of an hypothetical, and that's really damaging to the project.




I don't know if you realize, but you're being incredibly disrespectful with
almost everyone who has contributed anything in the last decade, treating
them as moles trying to bring down the project instead of contributing to
its success.


I would appreciate if you keep this emotional drama out. We need to look
with a clear head at this. Noone is disrespectful to people using ssh if
ssh is vulnerable.


It's not emotional drama, it's a fact. By your own admission you 
consider the GA, composed of almost every currently active developer, 
untrustworthy, vulnerable and in need to be scrapped or repurposed, with 
nothing to back that distrust other than hypotheticals about being an 
attack vector. Is that not being disrespectful to the people in it?


A potential "attack" to the GA can be worked around, as exemplified 
above. To request a complete redo of the system, arguments and actual 
events with considerable weight are needed. Otherwise, as i mentioned 
before, it will be perceived as someone asking for changes because they 
are unsatisfied.




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/2] swresample/rematrix: add support for custom order channel layouts

2025-02-02 Thread James Almer

On 2/2/2025 6:46 PM, James Almer wrote:

Limited to the same channels as a native layout, but not constrained by channel 
ordering.

Signed-off-by: James Almer 
---
Untested, as i don't have a sample from which we export a custom layout (Like 
PCM in mp4).


Tried with one such sample and it appears to work.



  libswresample/rematrix.c | 28 +---
  1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 8b6e8ae1c5..e3c2cc1211 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -104,6 +104,14 @@ static int clean_layout(AVChannelLayout *out, const 
AVChannelLayout *in, void *s
  }
  
  static int sane_layout(AVChannelLayout *ch_layout) {

+if(ch_layout->nb_channels >= SWR_CH_MAX)
+return 0;
+if(ch_layout->order == AV_CHANNEL_ORDER_CUSTOM)
+for (int i = 0; i < ch_layout->nb_channels; i++) {
+if (ch_layout->u.map[i].id >= 64)
+return 0;
+}
+else
  if (ch_layout->order != AV_CHANNEL_ORDER_NATIVE)
  return 0;
  if(!av_channel_layout_subset(ch_layout, AV_CH_LAYOUT_SURROUND)) // at 
least 1 front speaker
@@ -118,8 +126,6 @@ static int sane_layout(AVChannelLayout *ch_layout) {
  return 0;
  if(!even(av_channel_layout_subset(ch_layout, (AV_CH_TOP_FRONT_LEFT | 
AV_CH_TOP_FRONT_RIGHT
  return 0;
-if(ch_layout->nb_channels >= SWR_CH_MAX)
-return 0;
  
  return 1;

  }
@@ -130,9 +136,10 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
   ptrdiff_t stride, enum AVMatrixEncoding 
matrix_encoding)
  {
  double matrix[NUM_NAMED_CHANNELS][NUM_NAMED_CHANNELS]={{0}};
-uint64_t unaccounted = in_ch_layout->u.mask & ~out_ch_layout->u.mask;
+uint64_t unaccounted =  av_channel_layout_subset(in_ch_layout,  UINT64_MAX) 
&
+   ~av_channel_layout_subset(out_ch_layout, 
UINT64_MAX);
  double maxcoef=0;
-int i, j, out_i;
+int i, j;
  
  for(i=0; i
  if(   av_channel_layout_index_from_channel(in_ch_layout, i) >= 0
@@ -305,14 +312,15 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
  }
  
  
-for(out_i=i=0; i<64; i++){

+for(i=0; i<64; i++){
  double sum=0;
-int in_i=0;
-if (av_channel_layout_index_from_channel(out_ch_layout, i) < 0)
+int out_i = av_channel_layout_index_from_channel(out_ch_layout, i);
+if (out_i < 0)
  continue;
  for(j=0; j<64; j++){
-if (av_channel_layout_index_from_channel(in_ch_layout, j) < 0)
-   continue;
+int in_i = av_channel_layout_index_from_channel(in_ch_layout, j);
+if (in_i < 0)
+continue;
  if (i < FF_ARRAY_ELEMS(matrix) && j < FF_ARRAY_ELEMS(matrix[0]))
  matrix_param[stride*out_i + in_i] = matrix[i][j];
  else
@@ -320,10 +328,8 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
  (   av_channel_layout_index_from_channel(in_ch_layout, i) >= 0
   && av_channel_layout_index_from_channel(out_ch_layout, i) >= 
0);
  sum += fabs(matrix_param[stride*out_i + in_i]);
-in_i++;
  }
  maxcoef= FFMAX(maxcoef, sum);
-out_i++;
  }
  if(rematrix_volume  < 0)
  maxcoef = -rematrix_volume;




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 v2] libavcodec/mpeg12dec.c: rename 0x0502 CC format

2025-02-02 Thread Marth64
Will push
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] swresample/rematrix: split filling the matrix array into its own function

2025-02-02 Thread James Almer
Signed-off-by: James Almer 
---
 libswresample/rematrix.c | 202 ---
 1 file changed, 106 insertions(+), 96 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index b9bf4dcac0..8b6e8ae1c5 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -124,85 +124,28 @@ static int sane_layout(AVChannelLayout *ch_layout) {
 return 1;
 }
 
-av_cold int swr_build_matrix2(const AVChannelLayout *in_layout, const 
AVChannelLayout *out_layout,
-  double center_mix_level, double 
surround_mix_level,
-  double lfe_mix_level, double maxval,
-  double rematrix_volume, double *matrix_param,
-  ptrdiff_t stride, enum AVMatrixEncoding 
matrix_encoding, void *log_context)
+static void build_matrix(const AVChannelLayout *in_ch_layout, const 
AVChannelLayout *out_ch_layout,
+ double center_mix_level, double surround_mix_level,
+ double lfe_mix_level, double maxval, double 
rematrix_volume, double *matrix_param,
+ ptrdiff_t stride, enum AVMatrixEncoding 
matrix_encoding)
 {
-int i, j, out_i, ret;
-AVChannelLayout in_ch_layout = { 0 }, out_ch_layout = { 0 };
 double matrix[NUM_NAMED_CHANNELS][NUM_NAMED_CHANNELS]={{0}};
-int64_t unaccounted;
+uint64_t unaccounted = in_ch_layout->u.mask & ~out_ch_layout->u.mask;
 double maxcoef=0;
-char buf[128];
-
-ret  = clean_layout(&in_ch_layout, in_layout, log_context);
-ret |= clean_layout(&out_ch_layout, out_layout, log_context);
-if (ret < 0)
-goto fail;
-
-if(   !av_channel_layout_compare(&out_ch_layout, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX)
-   && !av_channel_layout_subset(&in_ch_layout, AV_CH_LAYOUT_STEREO_DOWNMIX)
-) {
-av_channel_layout_uninit(&out_ch_layout);
-out_ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
-}
-if(   !av_channel_layout_compare(&in_ch_layout, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX)
-   && !av_channel_layout_subset(&out_ch_layout, 
AV_CH_LAYOUT_STEREO_DOWNMIX)
-) {
-av_channel_layout_uninit(&in_ch_layout);
-in_ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
-}
-if (!av_channel_layout_compare(&in_ch_layout, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_22POINT2) &&
-av_channel_layout_compare(&out_ch_layout, 
&(AVChannelLayout)AV_CHANNEL_LAYOUT_22POINT2)) {
-av_channel_layout_from_mask(&in_ch_layout, 
(AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER));
-av_channel_layout_describe(&in_ch_layout, buf, sizeof(buf));
-av_log(log_context, AV_LOG_WARNING,
-   "Full-on remixing from 22.2 has not yet been implemented! "
-   "Processing the input as '%s'\n",
-   buf);
-}
-
-if(!av_channel_layout_check(&in_ch_layout)) {
-av_log(log_context, AV_LOG_ERROR, "Input channel layout is invalid\n");
-ret = AVERROR(EINVAL);
-goto fail;
-}
-if(!sane_layout(&in_ch_layout)) {
-av_channel_layout_describe(&in_ch_layout, buf, sizeof(buf));
-av_log(log_context, AV_LOG_ERROR, "Input channel layout '%s' is not 
supported\n", buf);
-ret = AVERROR(EINVAL);
-goto fail;
-}
-
-if(!av_channel_layout_check(&out_ch_layout)) {
-av_log(log_context, AV_LOG_ERROR, "Output channel layout is 
invalid\n");
-ret = AVERROR(EINVAL);
-goto fail;
-}
-if(!sane_layout(&out_ch_layout)) {
-av_channel_layout_describe(&out_ch_layout, buf, sizeof(buf));
-av_log(log_context, AV_LOG_ERROR, "Output channel layout '%s' is not 
supported\n", buf);
-ret = AVERROR(EINVAL);
-goto fail;
-}
+int i, j, out_i;
 
 for(i=0; i= 0
-   && av_channel_layout_index_from_channel(&out_ch_layout, i) >= 0)
+if(   av_channel_layout_index_from_channel(in_ch_layout, i) >= 0
+   && av_channel_layout_index_from_channel(out_ch_layout, i) >= 0)
 matrix[i][i]= 1.0;
 }
 
-unaccounted = in_ch_layout.u.mask & ~out_ch_layout.u.mask;
-
 //FIXME implement dolby surround
 //FIXME implement full ac3
 
-
 if(unaccounted & AV_CH_FRONT_CENTER){
-if (av_channel_layout_subset(&out_ch_layout, AV_CH_LAYOUT_STEREO) == 
AV_CH_LAYOUT_STEREO) {
-if (av_channel_layout_subset(&in_ch_layout, AV_CH_LAYOUT_STEREO)) {
+if (av_channel_layout_subset(out_ch_layout, AV_CH_LAYOUT_STEREO) == 
AV_CH_LAYOUT_STEREO) {
+if (av_channel_layout_subset(in_ch_layout, AV_CH_LAYOUT_STEREO)) {
 matrix[ FRONT_LEFT][FRONT_CENTER]+= center_mix_level;
 matrix[FRONT_RIGHT][FRONT_CENTER]+= center_mix_level;
 } else {
@@ -213,23 +156,23 @@ av_cold int swr_build_matrix2(const AVChannelLayout 
*in_layout, const AVChannelL
 av_assert0(0);

[FFmpeg-devel] [PATCH 2/2] swresample/rematrix: add support for custom order channel layouts

2025-02-02 Thread James Almer
Limited to the same channels as a native layout, but not constrained by channel 
ordering.

Signed-off-by: James Almer 
---
Untested, as i don't have a sample from which we export a custom layout (Like 
PCM in mp4).

 libswresample/rematrix.c | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 8b6e8ae1c5..e3c2cc1211 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -104,6 +104,14 @@ static int clean_layout(AVChannelLayout *out, const 
AVChannelLayout *in, void *s
 }
 
 static int sane_layout(AVChannelLayout *ch_layout) {
+if(ch_layout->nb_channels >= SWR_CH_MAX)
+return 0;
+if(ch_layout->order == AV_CHANNEL_ORDER_CUSTOM)
+for (int i = 0; i < ch_layout->nb_channels; i++) {
+if (ch_layout->u.map[i].id >= 64)
+return 0;
+}
+else
 if (ch_layout->order != AV_CHANNEL_ORDER_NATIVE)
 return 0;
 if(!av_channel_layout_subset(ch_layout, AV_CH_LAYOUT_SURROUND)) // at 
least 1 front speaker
@@ -118,8 +126,6 @@ static int sane_layout(AVChannelLayout *ch_layout) {
 return 0;
 if(!even(av_channel_layout_subset(ch_layout, (AV_CH_TOP_FRONT_LEFT | 
AV_CH_TOP_FRONT_RIGHT
 return 0;
-if(ch_layout->nb_channels >= SWR_CH_MAX)
-return 0;
 
 return 1;
 }
@@ -130,9 +136,10 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
  ptrdiff_t stride, enum AVMatrixEncoding 
matrix_encoding)
 {
 double matrix[NUM_NAMED_CHANNELS][NUM_NAMED_CHANNELS]={{0}};
-uint64_t unaccounted = in_ch_layout->u.mask & ~out_ch_layout->u.mask;
+uint64_t unaccounted =  av_channel_layout_subset(in_ch_layout,  
UINT64_MAX) &
+   ~av_channel_layout_subset(out_ch_layout, 
UINT64_MAX);
 double maxcoef=0;
-int i, j, out_i;
+int i, j;
 
 for(i=0; i= 0
@@ -305,14 +312,15 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
 }
 
 
-for(out_i=i=0; i<64; i++){
+for(i=0; i<64; i++){
 double sum=0;
-int in_i=0;
-if (av_channel_layout_index_from_channel(out_ch_layout, i) < 0)
+int out_i = av_channel_layout_index_from_channel(out_ch_layout, i);
+if (out_i < 0)
 continue;
 for(j=0; j<64; j++){
-if (av_channel_layout_index_from_channel(in_ch_layout, j) < 0)
-   continue;
+int in_i = av_channel_layout_index_from_channel(in_ch_layout, j);
+if (in_i < 0)
+continue;
 if (i < FF_ARRAY_ELEMS(matrix) && j < FF_ARRAY_ELEMS(matrix[0]))
 matrix_param[stride*out_i + in_i] = matrix[i][j];
 else
@@ -320,10 +328,8 @@ static void build_matrix(const AVChannelLayout 
*in_ch_layout, const AVChannelLay
 (   av_channel_layout_index_from_channel(in_ch_layout, i) >= 0
  && av_channel_layout_index_from_channel(out_ch_layout, i) >= 
0);
 sum += fabs(matrix_param[stride*out_i + in_i]);
-in_i++;
 }
 maxcoef= FFMAX(maxcoef, sum);
-out_i++;
 }
 if(rematrix_volume  < 0)
 maxcoef = -rematrix_volume;
-- 
2.48.1

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

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


Re: [FFmpeg-devel] libswresample/rematrix.c sane_layout

2025-02-02 Thread Pavel Koshevoy
On Sun, Feb 2, 2025 at 9:04 AM James Almer  wrote:

> On 1/30/2025 12:29 AM, Pavel Koshevoy wrote:
> > Hi,
> >
> > I have a file which I can't down-mix to stereo due to
> > AV_CHANNEL_ORDER_NATIVE requirement in sane_layout.
>
> Can you share that file? Or any other that reproduces this?
>
>
I will send you a 5s clip of the audio, privately ... don't want to spam
the whole mailing list with it.

Thank you,
Pavel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 1/2] avcodec/ffv1: split off and share frame header parsing code

2025-02-02 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/Makefile |   4 +-
 libavcodec/ffv1.c   |  14 +-
 libavcodec/ffv1.h   |  35 ++-
 libavcodec/ffv1_parse.c | 410 +++
 libavcodec/ffv1dec.c| 459 +++-
 libavcodec/ffv1enc.c|  14 +-
 6 files changed, 491 insertions(+), 445 deletions(-)
 create mode 100644 libavcodec/ffv1_parse.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a3ef11a258..44bb34182a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -368,8 +368,8 @@ OBJS-$(CONFIG_EVRC_DECODER)+= evrcdec.o 
acelp_vectors.o lsp.o
 OBJS-$(CONFIG_EXR_DECODER) += exr.o exrdsp.o half2float.o
 OBJS-$(CONFIG_EXR_ENCODER) += exrenc.o float2half.o
 OBJS-$(CONFIG_FASTAUDIO_DECODER)   += fastaudio.o
-OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1.o
-OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1.o
+OBJS-$(CONFIG_FFV1_DECODER)+= ffv1dec.o ffv1_parse.o ffv1.o
+OBJS-$(CONFIG_FFV1_ENCODER)+= ffv1enc.o ffv1_parse.o ffv1.o
 OBJS-$(CONFIG_FFV1_VULKAN_ENCODER) += ffv1enc.o ffv1.o ffv1enc_vulkan.o
 OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
 OBJS-$(CONFIG_FIC_DECODER) += fic.o
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index f303ed769f..54c2e7a8c6 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -33,10 +33,8 @@
 #include "ffv1.h"
 #include "libavutil/refstruct.h"
 
-av_cold int ff_ffv1_common_init(AVCodecContext *avctx)
+av_cold int ff_ffv1_common_init(AVCodecContext *avctx, FFV1Context *s)
 {
-FFV1Context *s = avctx->priv_data;
-
 if (!avctx->width || !avctx->height)
 return AVERROR_INVALIDDATA;
 
@@ -221,10 +219,13 @@ void ff_ffv1_clear_slice_state(const FFV1Context *f, 
FFV1SliceContext *sc)
 }
 }
 
+int ff_ffv1_get_symbol(RangeCoder *c, uint8_t *state, int is_signed)
+{
+return get_symbol_inline(c, state, is_signed);
+}
 
-av_cold int ff_ffv1_close(AVCodecContext *avctx)
+av_cold void ff_ffv1_close(FFV1Context *s)
 {
-FFV1Context *s = avctx->priv_data;
 int i, j;
 
 for (j = 0; j < s->max_slice_count; j++) {
@@ -238,7 +239,6 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
 
 av_refstruct_unref(&s->slice_damaged);
 
-av_freep(&avctx->stats_out);
 for (j = 0; j < s->quant_table_count; j++) {
 av_freep(&s->initial_states[j]);
 for (i = 0; i < s->max_slice_count; i++) {
@@ -249,6 +249,4 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
 }
 
 av_freep(&s->slices);
-
-return 0;
 }
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 419c53093f..583696a36e 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -28,6 +28,7 @@
  * FF Video Codec 1 (a lossless codec)
  */
 
+#include "libavutil/attributes.h"
 #include "avcodec.h"
 #include "get_bits.h"
 #include "mathops.h"
@@ -169,15 +170,20 @@ typedef struct FFV1Context {
 uint8_t   frame_damaged;
 } FFV1Context;
 
-int ff_ffv1_common_init(AVCodecContext *avctx);
+int ff_ffv1_common_init(AVCodecContext *avctx, FFV1Context *s);
 int ff_ffv1_init_slice_state(const FFV1Context *f, FFV1SliceContext *sc);
 int ff_ffv1_init_slices_state(FFV1Context *f);
 int ff_ffv1_init_slice_contexts(FFV1Context *f);
 PlaneContext *ff_ffv1_planes_alloc(void);
 int ff_ffv1_allocate_initial_states(FFV1Context *f);
 void ff_ffv1_clear_slice_state(const FFV1Context *f, FFV1SliceContext *sc);
-int ff_ffv1_close(AVCodecContext *avctx);
+void ff_ffv1_close(FFV1Context *s);
 int ff_need_new_slices(int width, int num_h_slices, int chroma_shift);
+int ff_ffv1_parse_header(FFV1Context *f, RangeCoder *c, uint8_t *state);
+int ff_ffv1_read_extra_header(FFV1Context *f);
+int ff_ffv1_read_quant_tables(RangeCoder *c,
+  int16_t quant_table[MAX_CONTEXT_INPUTS][256]);
+int ff_ffv1_get_symbol(RangeCoder *c, uint8_t *state, int is_signed);
 
 /**
  * This is intended for both width and height
@@ -223,4 +229,29 @@ static inline void update_vlc_state(VlcState *const state, 
const int v)
 state->count = count;
 }
 
+
+static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state,
+   int is_signed)
+{
+if (get_rac(c, state + 0))
+return 0;
+else {
+int e;
+unsigned a;
+e = 0;
+while (get_rac(c, state + 1 + FFMIN(e, 9))) { // 1..10
+e++;
+if (e > 31)
+return AVERROR_INVALIDDATA;
+}
+
+a = 1;
+for (int i = e - 1; i >= 0; i--)
+a += a + get_rac(c, state + 22 + FFMIN(i, 9));  // 22..31
+
+e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); // 11..21
+return (a ^ e) - e;
+}
+}
+
 #endif /* AVCODEC_FFV1_H */
diff --git a/libavcodec/ffv1_parse.c b/libavcodec/ffv1_parse.c
new file mode 100644
index 00..81224df214
--- /dev/null
+++ b/libavcodec/ffv1_parse.c
@@ -0,

[FFmpeg-devel] [PATCH v2 2/2] avcodec: add a ffv1 parser

2025-02-02 Thread James Almer
Only setting frame and stream properties. No packetization is performed.

Signed-off-by: James Almer 
---
 configure|  1 +
 libavcodec/Makefile  |  1 +
 libavcodec/ffv1_parser.c | 86 
 libavcodec/parsers.c |  1 +
 4 files changed, 89 insertions(+)
 create mode 100644 libavcodec/ffv1_parser.c

diff --git a/configure b/configure
index 06f641ead0..f09faaf505 100755
--- a/configure
+++ b/configure
@@ -3469,6 +3469,7 @@ vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec"
 aac_parser_select="adts_header mpeg4audio"
 av1_parser_select="cbs_av1"
 evc_parser_select="evcparse"
+ffv1_parser_select="rangecoder"
 ftr_parser_select="adts_header mpeg4audio"
 h264_parser_select="golomb h264dsp h264parse h264_sei"
 hevc_parser_select="hevcparse hevc_sei"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 44bb34182a..973e2c45d6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1207,6 +1207,7 @@ OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
 OBJS-$(CONFIG_EVC_PARSER)  += evc_parser.o
+OBJS-$(CONFIG_FFV1_PARSER) += ffv1_parser.o ffv1_parse.o ffv1.o
 OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
 OBJS-$(CONFIG_FTR_PARSER)  += ftr_parser.o
 OBJS-$(CONFIG_G723_1_PARSER)   += g723_1_parser.o
diff --git a/libavcodec/ffv1_parser.c b/libavcodec/ffv1_parser.c
new file mode 100644
index 00..d0b396b693
--- /dev/null
+++ b/libavcodec/ffv1_parser.c
@@ -0,0 +1,86 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avcodec.h"
+#include "ffv1.h"
+#include "rangecoder.h"
+
+typedef struct FFV1ParseContext {
+FFV1Context f;
+int got_first;
+} FFV1ParseContext;
+
+static int parse(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+FFV1ParseContext *p = s->priv_data;
+FFV1Context *f = &p->f;
+RangeCoder c;
+uint8_t keystate = 128;
+
+*poutbuf  = buf;
+*poutbuf_size = buf_size;
+
+if (!p->got_first) {
+int ret = ff_ffv1_common_init(avctx, f);
+p->got_first = 1;
+if (ret < 0)
+return buf_size;
+
+if (avctx->extradata_size > 0 && (ret = ff_ffv1_read_extra_header(f)) 
< 0)
+return buf_size;
+}
+
+ff_init_range_decoder(&c, buf, buf_size);
+ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8);
+
+f->avctx = avctx;
+s->key_frame = get_rac(&c, &keystate);
+s->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P, see ffv1dec.c
+s->field_order = AV_FIELD_UNKNOWN;
+s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
+
+if (s->key_frame) {
+uint8_t state[CONTEXT_SIZE];
+memset(state, 128, sizeof(state));
+ff_ffv1_parse_header(f, &c, state);
+}
+
+s->width  = f->width;
+s->height = f->height;
+s->format = f->pix_fmt;
+
+return buf_size;
+}
+
+static void close(AVCodecParserContext *s)
+{
+FFV1ParseContext *p = s->priv_data;
+
+p->f.avctx = NULL;
+ff_ffv1_close(&p->f);
+}
+
+const AVCodecParser ff_ffv1_parser = {
+.codec_ids= { AV_CODEC_ID_FFV1 },
+.priv_data_size = sizeof(FFV1ParseContext),
+.parser_parse = parse,
+.parser_close = close,
+};
diff --git a/libavcodec/parsers.c b/libavcodec/parsers.c
index 8bfd2dbce0..5387351fd0 100644
--- a/libavcodec/parsers.c
+++ b/libavcodec/parsers.c
@@ -45,6 +45,7 @@ extern const AVCodecParser ff_dvd_nav_parser;
 extern const AVCodecParser ff_evc_parser;
 extern const AVCodecParser ff_flac_parser;
 extern const AVCodecParser ff_ftr_parser;
+extern const AVCodecParser ff_ffv1_parser;
 extern const AVCodecParser ff_g723_1_parser;
 extern const AVCodecParser ff_g729_parser;
 extern const AVCodecParser ff_gif_parser;
-- 
2.48.1

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

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

Re: [FFmpeg-devel] Democratization work in progress draft v2

2025-02-02 Thread Ronald S. Bultje
Michael,

On Sat, Feb 1, 2025 at 4:53 PM Michael Niedermayer 
wrote:

> The system is absurd, the text points this out in a mocking/ironic way.
> If you want me to reword this in a dry formal way, i can submit such a
> patch?
>

Every system is absurd. "If everyone just agreed with me, then ..." There
are no perfect systems. If there were, everyone would use it.


> If not, how do you suggest we move forward here ?
> We can replace the GA by a system that is not vulnerable
> We can treat the GA more as guidance and not a final authority
> We can publish the issue and warn our users and leave it vulnerable
> We can try to block every choice, and treat this like any "publish after
> 90day"
>security issue (ffmpeg community refuses to fix or publish)
>

We could also do nothing.

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

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


Re: [FFmpeg-devel] [PATCH v4 1/2] avformat/riffdec: change declaration of ff_get_wav_header()

2025-02-02 Thread Viraaj Raulgaonkar
On Mon, Feb 3, 2025 at 12:56 AM Andreas Rheinhardt
 wrote:
>
> Viraaj Raulgaonkar:
> > Change the type of logctx from void* to AVFormatContext*, since all
> > calls to ff_get_wav_header() pass an AVFormatContext* anyway.
>
> This change makes it appear as if it were better to always pass an
> AVFormatContext* in such cases. But it is not so. Better commit message
> would be "This is in preparation for the following commit."

Ok, I'll change the commit message.

Thanks,
Viraaj

>
> - 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 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] [h264] Make slice header parse errors fatal under AV_EF_EXPLODE

2025-02-02 Thread Marth64
Pushing shortly
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 2/2] swresample/rematrix: add support for custom order channel layouts

2025-02-02 Thread Pavel Koshevoy
On Sun, Feb 2, 2025 at 4:04 PM James Almer  wrote:

> On 2/2/2025 6:46 PM, James Almer wrote:
> > Limited to the same channels as a native layout, but not constrained by
> channel ordering.
> >
> > Signed-off-by: James Almer 
> > ---
> > Untested, as i don't have a sample from which we export a custom layout
> (Like PCM in mp4).
>
> Tried with one such sample and it appears to work.
>
>
I've also applied both patches and tested with the full
COMMUNITY_HERO_2.mov -- it works fine.

Thank you,
Pavel.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v4 1/2] avformat/riffdec: change declaration of ff_get_wav_header()

2025-02-02 Thread Andreas Rheinhardt
Viraaj Raulgaonkar:
> Change the type of logctx from void* to AVFormatContext*, since all
> calls to ff_get_wav_header() pass an AVFormatContext* anyway.

This change makes it appear as if it were better to always pass an
AVFormatContext* in such cases. But it is not so. Better commit message
would be "This is in preparation for the following commit."

- 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 v5 1/2] avformat/riffdec: change declaration of ff_get_wav_header()

2025-02-02 Thread Viraaj Raulgaonkar
Change the type of logctx from void* to AVFormatContext*. This is in
preparation for the next commit.
---
 libavformat/riff.h|  2 +-
 libavformat/riffdec.c | 14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavformat/riff.h b/libavformat/riff.h
index a93eadfeca..0b01b1fd20 100644
--- a/libavformat/riff.h
+++ b/libavformat/riff.h
@@ -67,7 +67,7 @@ void ff_put_bmp_header(AVIOContext *pb, AVCodecParameters 
*par, int for_asf, int
 int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters 
*par, int flags);
 
 enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps);
-int ff_get_wav_header(void *logctx, AVIOContext *pb, AVCodecParameters *par,
+int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters 
*par,
   int size, int big_endian);
 
 extern const AVCodecTag ff_codec_bmp_tags[]; // exposed through 
avformat_get_riff_video_tags()
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index b7a85a6ab2..2b269b1682 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -92,14 +92,14 @@ static void parse_waveformatex(void *logctx, AVIOContext 
*pb, AVCodecParameters
 }
 
 /* "big_endian" values are needed for RIFX file format */
-int ff_get_wav_header(void *logctx, AVIOContext *pb,
+int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
   AVCodecParameters *par, int size, int big_endian)
 {
 int id, channels = 0, ret;
 uint64_t bitrate = 0;
 
 if (size < 14) {
-avpriv_request_sample(logctx, "wav header size < 14");
+avpriv_request_sample(s, "wav header size < 14");
 return AVERROR_INVALIDDATA;
 }
 
@@ -140,18 +140,18 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb,
 if (size >= 18 && id != 0x0165) {  /* We're obviously dealing with 
WAVEFORMATEX */
 int cbSize = avio_rl16(pb); /* cbSize */
 if (big_endian) {
-avpriv_report_missing_feature(logctx, "WAVEFORMATEX support for 
RIFX files");
+avpriv_report_missing_feature(s, "WAVEFORMATEX support for RIFX 
files");
 return AVERROR_PATCHWELCOME;
 }
 size  -= 18;
 cbSize = FFMIN(size, cbSize);
 if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
-parse_waveformatex(logctx, pb, par);
+parse_waveformatex(s, pb, par);
 cbSize -= 22;
 size   -= 22;
 }
 if (cbSize > 0) {
-ret = ff_get_extradata(logctx, par, pb, cbSize);
+ret = ff_get_extradata(s, par, pb, cbSize);
 if (ret < 0)
 return ret;
 size -= cbSize;
@@ -164,7 +164,7 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb,
 int nb_streams, i;
 
 size -= 4;
-ret = ff_get_extradata(logctx, par, pb, size);
+ret = ff_get_extradata(s, par, pb, size);
 if (ret < 0)
 return ret;
 nb_streams = AV_RL16(par->extradata + 4);
@@ -180,7 +180,7 @@ int ff_get_wav_header(void *logctx, AVIOContext *pb,
 par->bit_rate = bitrate;
 
 if (par->sample_rate <= 0) {
-av_log(logctx, AV_LOG_ERROR,
+av_log(s, AV_LOG_ERROR,
"Invalid sample rate: %d\n", par->sample_rate);
 return AVERROR_INVALIDDATA;
 }
-- 
2.39.5

___
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 v5 2/2] avformat/riffdec: warn on invalid sample rate

2025-02-02 Thread Viraaj Raulgaonkar
If strict_std_compliance < FF_COMPLIANCE_STRICT, warn the user of the
invalid sample rate instead of returning an error. In certain cases the
sample rate can get decoded later on.

Fixes Trac Ticket #11361.
---
 libavformat/riffdec.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 2b269b1682..a3eee43a41 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -180,9 +180,12 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
 par->bit_rate = bitrate;
 
 if (par->sample_rate <= 0) {
-av_log(s, AV_LOG_ERROR,
+int strict = s->strict_std_compliance >= FF_COMPLIANCE_STRICT;
+av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING,
"Invalid sample rate: %d\n", par->sample_rate);
-return AVERROR_INVALIDDATA;
+if (strict)
+return AVERROR_INVALIDDATA;
+par->sample_rate = 0;
 }
 if (par->codec_id == AV_CODEC_ID_AAC_LATM) {
 /* Channels and sample_rate values are those prior to applying SBR
-- 
2.39.5

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

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


Re: [FFmpeg-devel] [PATCH v2 2/2] avcodec: add a ffv1 parser

2025-02-02 Thread Lynne

On 03/02/2025 03:16, James Almer wrote:

Only setting frame and stream properties. No packetization is performed.

Signed-off-by: James Almer 
---
  configure|  1 +
  libavcodec/Makefile  |  1 +
  libavcodec/ffv1_parser.c | 86 
  libavcodec/parsers.c |  1 +
  4 files changed, 89 insertions(+)
  create mode 100644 libavcodec/ffv1_parser.c

diff --git a/configure b/configure
index 06f641ead0..f09faaf505 100755
--- a/configure
+++ b/configure
@@ -3469,6 +3469,7 @@ vvc_qsv_decoder_select="vvc_mp4toannexb_bsf qsvdec"
  aac_parser_select="adts_header mpeg4audio"
  av1_parser_select="cbs_av1"
  evc_parser_select="evcparse"
+ffv1_parser_select="rangecoder"
  ftr_parser_select="adts_header mpeg4audio"
  h264_parser_select="golomb h264dsp h264parse h264_sei"
  hevc_parser_select="hevcparse hevc_sei"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 44bb34182a..973e2c45d6 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1207,6 +1207,7 @@ OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
  OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
  OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
  OBJS-$(CONFIG_EVC_PARSER)  += evc_parser.o
+OBJS-$(CONFIG_FFV1_PARSER) += ffv1_parser.o ffv1_parse.o ffv1.o
  OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
  OBJS-$(CONFIG_FTR_PARSER)  += ftr_parser.o
  OBJS-$(CONFIG_G723_1_PARSER)   += g723_1_parser.o
diff --git a/libavcodec/ffv1_parser.c b/libavcodec/ffv1_parser.c
new file mode 100644
index 00..d0b396b693
--- /dev/null
+++ b/libavcodec/ffv1_parser.c
@@ -0,0 +1,86 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avcodec.h"
+#include "ffv1.h"
+#include "rangecoder.h"
+
+typedef struct FFV1ParseContext {
+FFV1Context f;
+int got_first;
+} FFV1ParseContext;
+
+static int parse(AVCodecParserContext *s,
+ AVCodecContext *avctx,
+ const uint8_t **poutbuf, int *poutbuf_size,
+ const uint8_t *buf, int buf_size)
+{
+FFV1ParseContext *p = s->priv_data;
+FFV1Context *f = &p->f;
+RangeCoder c;
+uint8_t keystate = 128;
+
+*poutbuf  = buf;
+*poutbuf_size = buf_size;
+
+if (!p->got_first) {
+int ret = ff_ffv1_common_init(avctx, f);
+p->got_first = 1;
+if (ret < 0)
+return buf_size;
+
+if (avctx->extradata_size > 0 && (ret = ff_ffv1_read_extra_header(f)) 
< 0)
+return buf_size;
+}
+
+ff_init_range_decoder(&c, buf, buf_size);
+ff_build_rac_states(&c, 0.05 * (1LL << 32), 256 - 8);
+
+f->avctx = avctx;
+s->key_frame = get_rac(&c, &keystate);
+s->pict_type = AV_PICTURE_TYPE_I; //FIXME I vs. P, see ffv1dec.c
+s->field_order = AV_FIELD_UNKNOWN;
+s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
+
+if (s->key_frame) {
+uint8_t state[CONTEXT_SIZE];
+memset(state, 128, sizeof(state));
+ff_ffv1_parse_header(f, &c, state);
+}
+
+s->width  = f->width;
+s->height = f->height;
+s->format = f->pix_fmt;
+
+return buf_size;
+}
+
+static void close(AVCodecParserContext *s)
+{
+FFV1ParseContext *p = s->priv_data;
+
+p->f.avctx = NULL;


Since avctx looks like is only used for logging now in parse_header, you 
could cast AVCodecParserContext and avoid av_log(NULL)s on error.


Other than that, patchset looks good to me, thanks.


OpenPGP_0xA2FEA5F03F034464.asc
Description: OpenPGP public key


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] Democratization work in progress draft v2

2025-02-02 Thread Michael Niedermayer
Hi

On Sat, Feb 01, 2025 at 02:45:26PM +0800, Zhao Zhili wrote:
> 
> 
> > On Feb 1, 2025, at 08:49, Michael Niedermayer  
> > wrote:
> > 
> > Hi James
> > 
> > On Fri, Jan 31, 2025 at 12:44:50PM -0300, James Almer wrote:
> >> On 1/31/2025 11:58 AM, Nicolas George wrote:
> >>> Niklas Haas (12025-01-30):
> > [...]
> >>> On the other hand, I believe this whole plan is a bad idea.
> >> Yes, it is a bad idea. We have had the current system in place for about
> >> five years now, and besides one or two CC assemblages being inefficient, it
> > 
> > Do you remember this suggested addition to the FAQ ?
> > https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2025-January/338186.html
> > 
> 
> The proposal treat every GA member as suspect, and GA members with daily jobs 
> guilty.

The text i proposed for the FAQ was intended to raise the issue with an humours 
tone
and wasnt meant to be taken litteral.


> 
> The community should be based on trust and everyone should be trust equally, 
> unless
> he/she did something not worth the trust. The 20 patches threshold for GA is 
> a prove
> of basic understanding of the project and the willingness to participate, not 
> means
> someone with more patches has more weight when vote on community activities.

yes but its not so simple

Open source projects have increasingly become the target for supply chain 
attacks.
In some cases multiple people over year long periods have participated in such 
attacks

If we look at governance in democratic countries. Vote buying has repeatly 
happened.

If we look at governance in crypto. hundreds of millions where stolen through
governance attacks.

(you can find examples for above by asking chatgpt or a search engine)

FFmpeg is used by billions of people indirectly, we are not a small unimportant
project that noone cares about.

I think, its dangerous for us to say, "it will not happen to us"
its safer to make the system more robust

thx

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

Some Animals are More Equal Than Others. - George Orwell's book Animal Farm


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] lavc/vvc: Fix derivation of inverse LMCS idx

2025-02-02 Thread Frank Plowman
The clamping of idxYInv from H.266(V3) section 8.8.2.3 was missing.
This could lead to OOB reads from lmcs->pivot or input_pivot.

I also changed the derivation of the forward LMCS idx to use a shift
rather than a division for speed and as this is actually how the
variable is declared in the specification (8.7.5.2).

Signed-off-by: Frank Plowman 
---
 libavcodec/vvc/ps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c
index 01b4615eda..fae6655cc0 100644
--- a/libavcodec/vvc/ps.c
+++ b/libavcodec/vvc/ps.c
@@ -786,7 +786,7 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS 
*rlmcs, const H266Raw
 
 //derive lmcs_fwd_lut
 for (uint16_t sample = 0; sample < max; sample++) {
-const int idx_y = sample / org_cw;
+const int idx_y = sample >> shift;
 const uint16_t fwd_sample = lmcs_derive_lut_sample(sample, lmcs->pivot,
 input_pivot, scale_coeff, idx_y, max);
 if (bit_depth > 8)
@@ -802,6 +802,7 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS 
*rlmcs, const H266Raw
 uint16_t inv_sample;
 while (i <= lmcs->max_bin_idx && sample >= lmcs->pivot[i + 1])
 i++;
+i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
 
 inv_sample = lmcs_derive_lut_sample(sample, input_pivot, lmcs->pivot,
 inv_scale_coeff, i, max);
-- 
2.47.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".