[FFmpeg-devel] [PATCH] vaapi_encode_h264: set deblocking filter control present flag to 1

2025-04-16 Thread Ilecki, Milosz
Signed-off-by: Ilecki, Milosz 
---
 libavcodec/vaapi_encode_h264.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 0cd5b0ac50..5c9c4cd977 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -366,6 +366,8 @@ static int 
vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
 .time_scale= sps->vui.time_scale,
 };
 
+pps->deblocking_filter_control_present_flag = 1;
+
 *vpic = (VAEncPictureParameterBufferH264) {
 .CurrPic = {
 .picture_id = VA_INVALID_ID,
-- 
2.43.5

-
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial 
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | 
Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z 
dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach 
handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i 
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej 
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; 
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole 
use of the intended recipient(s). If you are not the intended recipient, please 
contact the sender and delete all copies; any review or distribution by others 
is strictly prohibited.

___
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] vulkan: use a single command buffer per command buffer pool

2025-04-16 Thread Lynne
We violated the spec, which, despite the actual command buffer pool
*not* being involved in any functions which require external synchronization
of the pool, *require* external synchronization even if only the
command buffers are used.

This also has the effect of *significantly* speeding up execution
in case command buffers are contended.
---
 libavutil/hwcontext_vulkan.c |  1 -
 libavutil/vulkan.c   | 78 +---
 libavutil/vulkan.h   |  2 +-
 3 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 32203b2f06..d7822d4629 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -673,7 +673,6 @@ static VkBool32 VKAPI_CALL 
vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEX
 case 0xfd92477a: /* BestPractices-vkAllocateMemory-small-allocation */
 case 0x618ab1e7: /* VUID-VkImageViewCreateInfo-usage-02275 */
 case 0x30f4ac70: /* VUID-VkImageCreateInfo-pNext-06811 */
-case 0xa05b236e: /* UNASSIGNED-Threading-MultipleThreads-Write */
 return VK_FALSE;
 default:
 break;
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index d880d52272..8f444b2dfe 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -280,15 +280,19 @@ void ff_vk_exec_pool_free(FFVulkanContext *s, 
FFVkExecPool *pool)
 av_freep(&sd->desc_sets);
 }
 
-if (pool->cmd_bufs)
-vk->FreeCommandBuffers(s->hwctx->act_dev, pool->cmd_buf_pool,
-   pool->pool_size, pool->cmd_bufs);
-if (pool->cmd_buf_pool)
-vk->DestroyCommandPool(s->hwctx->act_dev, pool->cmd_buf_pool, 
s->hwctx->alloc);
+for (int i = 0; i < pool->pool_size; i++) {
+if (pool->cmd_buf_pools[i])
+vk->FreeCommandBuffers(s->hwctx->act_dev, pool->cmd_buf_pools[i],
+   1, &pool->cmd_bufs[i]);
+
+if (pool->cmd_buf_pools[i])
+vk->DestroyCommandPool(s->hwctx->act_dev, pool->cmd_buf_pools[i], 
s->hwctx->alloc);
+}
 if (pool->query_pool)
 vk->DestroyQueryPool(s->hwctx->act_dev, pool->query_pool, 
s->hwctx->alloc);
 
 av_free(pool->query_data);
+av_free(pool->cmd_buf_pools);
 av_free(pool->cmd_bufs);
 av_free(pool->contexts);
 }
@@ -316,19 +320,10 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, 
AVVulkanDeviceQueueFamily *qf,
 return AVERROR(EINVAL);
 }
 
-/* Create command pool */
-cqueue_create = (VkCommandPoolCreateInfo) {
-.sType  = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
-.flags  = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
-  VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
-.queueFamilyIndex   = qf->idx,
-};
-ret = vk->CreateCommandPool(s->hwctx->act_dev, &cqueue_create,
-s->hwctx->alloc, &pool->cmd_buf_pool);
-if (ret != VK_SUCCESS) {
-av_log(s, AV_LOG_ERROR, "Command pool creation failure: %s\n",
-   ff_vk_ret2str(ret));
-err = AVERROR_EXTERNAL;
+/* Allocate space for command buffer pools */
+pool->cmd_buf_pools = av_malloc(nb_contexts*sizeof(*pool->cmd_buf_pools));
+if (!pool->cmd_buf_pools) {
+err = AVERROR(ENOMEM);
 goto fail;
 }
 
@@ -339,20 +334,39 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, 
AVVulkanDeviceQueueFamily *qf,
 goto fail;
 }
 
-/* Allocate command buffer */
-cbuf_create = (VkCommandBufferAllocateInfo) {
-.sType  = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
-.level  = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
-.commandPool= pool->cmd_buf_pool,
-.commandBufferCount = nb_contexts,
-};
-ret = vk->AllocateCommandBuffers(s->hwctx->act_dev, &cbuf_create,
- pool->cmd_bufs);
-if (ret != VK_SUCCESS) {
-av_log(s, AV_LOG_ERROR, "Command buffer alloc failure: %s\n",
-   ff_vk_ret2str(ret));
-err = AVERROR_EXTERNAL;
-goto fail;
+for (int i = 0; i < nb_contexts; i++) {
+/* Create command pool */
+cqueue_create = (VkCommandPoolCreateInfo) {
+.sType  = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
+.flags  = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
+  
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
+.queueFamilyIndex   = qf->idx,
+};
+
+ret = vk->CreateCommandPool(s->hwctx->act_dev, &cqueue_create,
+s->hwctx->alloc, &pool->cmd_buf_pools[i]);
+if (ret != VK_SUCCESS) {
+av_log(s, AV_LOG_ERROR, "Command pool creation failure: %s\n",
+   ff_vk_ret2str(ret));
+err = AVERROR_EXTERNAL;
+goto fail;
+}
+
+/* Allocate command buffer */
+cbuf_c

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: add avformat_query_seekable

2025-04-16 Thread Gyan Doshi




On 2025-04-16 10:37 am, Andreas Rheinhardt wrote:

Gyan Doshi:

Utility function to report seekability features for a given input.

Useful for ffprobe and to extend seek possibilities in fftools.
---
v2:
made constants more descriptive
add exception for rtsp false negative seekability

  doc/APIchanges |  3 +++
  libavformat/avformat.h | 22 ++
  libavformat/seek.c | 53 ++
  libavformat/version.h  |  2 +-
  4 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..879f56b572 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
  
  API changes, most recent first:
  
+2025-04-xx - xx - lavf 62.1.100 - avformat.h

+  Add avformat_query_seekable().
+
  2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
Add AV_DICT_DEDUP.
  
diff --git a/libavformat/avformat.h b/libavformat/avformat.h

index 498c3020a5..f9da5e9e79 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2338,6 +2338,28 @@ int av_seek_frame(AVFormatContext *s, int stream_index, 
int64_t timestamp,
   */
  int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, 
int64_t ts, int64_t max_ts, int flags);
  
+#define AVSEEKABLE_IO_NORMAL   0x0001 ///< I/O is seekable like a local file

+#define AVSEEKABLE_IO_PROTOCOL 0x0002 ///< I/O seek is through 
protocol request via avio_seek_time
+#define AVSEEKABLE_VIA_DEMUXER 0x0004 ///< demuxer has a seek function
+#define AVSEEKABLE_VIA_PKTSCAN 0x0008 ///< seek is performed by 
consuming and scanning packet timestamps
+#define AVSEEKABLE_BY_TIME 0x0100 ///< seek target can be a 
timestamp
+#define AVSEEKABLE_BY_BYTE 0x0200 ///< seek target can be in bytes
+#define AVSEEKABLE_BY_FRAME0x0400 ///< seek target can be a frame 
index
+#define AVSEEKABLE_PROP_PTS0x0001 ///< seek target timestamp is 
expected to be PTS
+#define AVSEEKABLE_PROP_FAST   0x0002 ///< demuxer allows fast but 
inaccurate seeking
+#define AVSEEKABLE_PROP_FWDONLY0x0004 ///< set seek will be equal or 
forward of specified seek point
+
+/**
+ * Report if and how a seek can be performed in a given input.
+ *
+ * @param smedia file handle
+ *
+ * @return 0 if no seek can be performed on input,
+ * -1 if the fmt ctx is NULL or is not an input
+ * else return AVSEEKABLE_ bitflags indicating seekability features.
+ */
+int avformat_query_seekable(AVFormatContext *s);
+
  /**
   * Discard all internally buffered data. This can be useful when dealing with
   * discontinuities in the byte stream. Generally works only with formats that
diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6..8be1bdec30 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -712,6 +712,59 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
  return ret;
  }
  
+int avformat_query_seekable(AVFormatContext *s)

+{
+int ret = 0;
+
+if (!s || !s->iformat)
+return -1;
+
+if ( strcmp(s->iformat->name, "rtsp") && (!(s->pb && s->pb->seekable) || 
s->ctx_flags & AVFMTCTX_UNSEEKABLE) )
+return 0;
+
+if (s->pb->seekable & AVIO_SEEKABLE_NORMAL)
+ret |= AVSEEKABLE_IO_NORMAL;
+
+if (s->pb->seekable & AVIO_SEEKABLE_TIME)
+ret |= AVSEEKABLE_IO_PROTOCOL;
+
+if (ffifmt(s->iformat)->read_seek || ffifmt(s->iformat)->read_seek2)
+ret |= AVSEEKABLE_VIA_DEMUXER;

The existence of these functions does not imply that a given input is
seekable: E.g. some read_seek functions rely on an index being present
in the file and are useless/not better than reading linearly in case the
index is absent.


Seek performance is a secondary concern.
Basic seek support means that the client can reduce the number of 
packets they have to deal with before they start receiving the desired 
packets.
If the demuxer or framework needs to scan and discard packets 
individually, that's still a seek being carried out.


Nonetheless, I've added a flag for 'slow' seeking and added that for 
packet scanned seeking.
Fur fully qualified reporting, the flags in demuxers will need to be 
updated. That's next on my todo after the basic functionality is present.


Regards,
Gyan

___
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] fate/vvc: Add vvc-wpp-single-slice-pic

2025-04-16 Thread Frank Plowman
On 16/04/2025 14:30, Nuo Mi wrote:
> Thank you, Frank.
> 
> Hi samples-request,
> could you help
> 
> On Wed, Apr 9, 2025 at 12:29 AM Frank Plowman  wrote:
> 
>> On 24/03/2025 18:10, Frank Plowman wrote:
>>> A sample with a particular partitioning structure that could not be read
>>> correctly before 26c5d8cf5d6dcd520e781754d986e9907d74270e
>>>
>>> Signed-off-by: Frank Plowman 
>>> ---
>>>  tests/fate/vvc.mak  | 10 ++
>>>  tests/ref/fate/vvc-wpp-single-slice-pic |  6 ++
>>>  2 files changed, 12 insertions(+), 4 deletions(-)
>>>  create mode 100644 tests/ref/fate/vvc-wpp-single-slice-pic
>>>
>>> diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
>>> index 532bf44e19..c882010713 100644
>>> --- a/tests/fate/vvc.mak
>>> +++ b/tests/fate/vvc.mak
>>> @@ -44,12 +44,14 @@ $(VVC_TESTS_444_10BIT): SCALE_OPTS := -pix_fmt
>> yuv444p10le -vf scale
>>>  fate-vvc-conformance-%: CMD = framecrc -c:v vvc -i
>> $(TARGET_SAMPLES)/vvc-conformance/$(subst fate-vvc-conformance-,,$(@)).bit
>> $(SCALE_OPTS)
>>>  fate-vvc-output-ref: CMD = framecrc -c:v vvc -i
>> $(TARGET_SAMPLES)/vvc/Hierarchical.bit $(SCALE_OPTS)
>>>  fate-vvc-frames-with-ltr: CMD = framecrc -c:v vvc -i
>> $(TARGET_SAMPLES)/vvc/vvc_frames_with_ltr.vvc -pix_fmt yuv420p10le -vf scale
>>> +fate-vvc-wpp-single-slice-pic: CMD = framecrc -c:v vvc -i
>> $(TARGET_SAMPLES)/vvc/wpp-single-slice-pic.vvc -pix_fmt yuv420p10le -vf
>> scale
>>>
>>>  FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER) += $(VVC_TESTS_8BIT)
>> fate-vvc-output-ref
>>> -FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER SCALE_FILTER) +=
>>   \
>>> -$(VVC_TESTS_10BIT)
>>  \
>>> -
>> $(VVC_TESTS_444_10BIT)   \
>>> -
>> fate-vvc-frames-with-ltr \
>>> +FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER SCALE_FILTER) +=
>>\
>>> +$(VVC_TESTS_10BIT)
>>   \
>>> +
>> $(VVC_TESTS_444_10BIT)\
>>> +
>> fate-vvc-frames-with-ltr  \
>>> +
>> fate-vvc-wpp-single-slice-pic \
>>>
>>>  FATE_SAMPLES_FFMPEG += $(FATE_VVC-yes)
>>>
>>> diff --git a/tests/ref/fate/vvc-wpp-single-slice-pic
>> b/tests/ref/fate/vvc-wpp-single-slice-pic
>>> new file mode 100644
>>> index 00..d3629a8d80
>>> --- /dev/null
>>> +++ b/tests/ref/fate/vvc-wpp-single-slice-pic
>>> @@ -0,0 +1,6 @@
>>> +#tb 0: 1/25
>>> +#media_type 0: video
>>> +#codec_id 0: rawvideo
>>> +#dimensions 0: 256x256
>>> +#sar 0: 0/1
>>> +0,  0,  0,1,   196608, 0x49771161
>>
>> Ping
>>
>> ___
>> 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".

I believe the sample is already uploaded to the FATE rsync, it's just
this patch that needs pushing.

-- 
Frank

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

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


Re: [FFmpeg-devel] [PATCH] fftools/textformat/avtextformat: Remove unused variable

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 16. April 2025 18:59
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] [PATCH] fftools/textformat/avtextformat:
> Remove unused variable
> 
> Patch attached. Will apply it tonight. Sorry for the issue.
> 
> - Andreas


No worries, all fine. I still have to analyze my own "new warnings" anyway.

Thanks a lot
sw
___
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 v10 2/3] fftools: add mem log flag and disable printing addresses by default

2025-04-16 Thread Gyan Doshi



On 2025-04-16 07:20 pm, Nicolas George wrote:

Michael Niedermayer (HE12025-04-16):

I think some way to distingish two different "hevc" instances
with high probability should remain.

This is exactly my point. The address is meaningless¹, but it is a sure
way to distinguish instances of the same components without tons of
fragile code.


For CLI users, the fftool log prefixes already identify the input file 
and the stream in many msgs, e.g.


e.g. [vist#0:0/h264 @ 02485a204540] [dec:h264 @ 02485a36e900] 
Decoder thread received EOF packet


So, an opt-in flag should be added even if it's not made the default, or 
no UUID replacement is found for the memaddr.


Regards,
Gyan

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

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


[FFmpeg-devel] [PATCH] fftools/textformat/avtextformat: Remove unused variable

2025-04-16 Thread Andreas Rheinhardt
Patch attached. Will apply it tonight. Sorry for the issue.

- Andreas
From cd181ac93b939b27b81ac9e2ff8b48c675bab83f Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Wed, 16 Apr 2025 18:57:46 +0200
Subject: [PATCH] fftools/textformat/avtextformat: Remove unused variable

Forgotten in a888975a3c25760027cd59932f5c1ad04368db8b.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/textformat/avtextformat.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 44085fc87a..9200b9b1ad 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -585,7 +585,6 @@ static const AVClass textwriter_class = {
 void avtextwriter_context_close(AVTextWriterContext **pwctx)
 {
 AVTextWriterContext *wctx = *pwctx;
-int ret = 0;
 
 if (!wctx)
 return;
-- 
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 v10 2/3] fftools: add mem log flag and disable printing addresses by default

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 15:43
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v10 2/3] fftools: add mem log flag
> and disable printing addresses by default
> 
> Hi
> 
> On Thu, Apr 10, 2025 at 08:51:04AM +0200, Nicolas George wrote:
> > softworkz (HE12025-04-10):
> > > From: softworkz 
> > >
> > > This commit adds the mem log flag.
> > > When specifying this flag at the command line, context prefixes
> will
> > > be printed with memory addresses like in earlier ffmpeg versions.
> > >
> > > Example with mem flag:
> > >
> > > [hevc @ 018e72a89cc0] .
> >
> > As explained recently, strong opposition to this being the default.
> 
> just some random comments:
> 
> I think some way to distingish two different "hevc" instances
> with high probability should remain.
> 
> About the addresses. Iam curious how frequently do people use them ?
> and for what exactly ?
> 
> I do think *item_name() should be used more often. The "hevc" is a
> quite bland identifcation of the instance.
> 
> in absence of a item_name(), that is *av_default_item_name()
> which prints just the class name. I think printing the address by
> default
> is reasonable otherwsie instances would be always indistingishable
> 
> beyond that, i dont remember using the addresses and would not
> mind if it gets replaced by something more usefull more repeatable
> with maybe some mem flag that could force them to be printed in all
> cases
> 
> but i dont know, really depends on what the community prefers


Thanks Michael,

I'm gonna keep myself out of arguing, I believe that this is a decision
that should be based on what the community (majority) will prefer.

I just want to summarize the different implementations that are available
already while the patchset has walked its way through the various comments 
that were made.

-

1. Implementation in avutil with replacement Ids
   The replacement Ids are a direct projection of the mem addresses, which
   means that they are equally evident - yet subject to the same limitations
   as the mem-addresses.
   But other than the mem-addresses, this creates the identical log output
   when repeating the same command.

Reviews:

- It has been criticized that this introduces global state which is 
  undesired in case of library use
- It has been suggested to implement this in fftools only, in a way that
  fftools has its own and independent logging implementation, no longer
  using the one in avutil. It was also based on the idea that this would 
  allow to do other things in the future which cannot reasonably be 
  implemented in avutil

This has led to the second variant:

-

2. Implementation in fftools with replacement Ids
   Replacement Id behavior is the same as in (1).
   Obviously, there's no point in writing this from scratch, so the starting
   point was the logging code from avutil

Reviews:

- This has raised criticism due to the copied logging code
- It was suggested to drop the replacement Ids and then it could be
  implemented in avutil only

This has led to the third version:

-

3. Implementation back in avutil without Ids

   Means you switch the mem addresses on or off, when off, no Ids are printed

-


Best regards,
softworkz
___
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] [NOT for git] avutil/tests/map: benchmark code [BENCHMARK included]

2025-04-16 Thread Michael Niedermayer
On Tue, Apr 15, 2025 at 11:24:37PM +, softworkz . wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Dienstag, 15. April 2025 22:51
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: [FFmpeg-devel] [PATCH v3] [NOT for git] avutil/tests/map:
> > benchmark code [BENCHMARK included]
> > 
> 
> [..]
> 
> > 
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavutil/tests/map.c | 57
> > +++
> >  1 file changed, 57 insertions(+)
> > 
> > diff --git a/libavutil/tests/map.c b/libavutil/tests/map.c
> > index 38f0a153e68..90950769f98 100644
> > --- a/libavutil/tests/map.c
> > +++ b/libavutil/tests/map.c
> > @@ -26,6 +26,8 @@
> >  #include "libavutil/mem.h"
> >  #include "libavutil/map.h"
> > 
> > +#include "libavutil/timer.h"
> > +#include "libavutil/dict.h"
> > 
> >  static void print_set(const AVMap *s)
> >  {
> > @@ -37,6 +39,7 @@ static void print_set(const AVMap *s)
> > 
> >  int main(void)
> >  {
> > +#if 0
> >  void *our_cmp[] = {
> >  strcmp,
> >  av_map_strcmp_keyvalue,
> > @@ -185,6 +188,60 @@ int main(void)
> >  av_map_free(&set);
> >  av_assert0(!set);
> >  }
> > +#else
> > +#define N_ENTRIES 1000
> > +#define P 4
> > +fprintf(stderr, "%d entries variable bytes at location %d-%d\n",
> > N_ENTRIES, P, P+1);
> > +for (int runs = 0; runs < 1000; runs++) {
> > +AVMap *map = av_map_new(av_strcasecmp, NULL, NULL);
> > +for(int pass = 0; pass < 2; pass++) {
> > +START_TIMER
> > +unsigned r = 5;
> > +for(int i=0; i > +r = r*123 + 7;
> > +char str[7] = "TEST";
> > +str[P  ] = r;
> > +str[P+1] = r>>8;
> > +if(pass == 0) {
> > +av_map_add(map, str, 7, str, 7, 0);
> > +} else {
> > +av_map_get(map, str, av_strcasecmp);
> > +}
> > +}
> > +if (pass) {
> > +STOP_TIMER("av_map_get")
> > +} else {
> > +STOP_TIMER("av_map_add")
> > +}
> > +}
> > +av_map_free(&map);
> > +}
> > +
> > +for (int runs = 0; runs < 1000; runs++) {
> > +AVDictionary *dict = NULL;
> > +for(int pass = 0; pass < 2; pass++) {
> > +START_TIMER
> > +unsigned r = 5;
> > +for(int i=0; i > +r = r*123 + 7;
> > +char str[7] = "TEST";
> > +str[P  ] = r;
> > +str[P+1] = r>>8;
> > +if(pass == 0) {
> > +av_dict_set(&dict, str, str, 0);
> > +} else {
> > +av_dict_get(dict, str, NULL, 0);
> > +}
> > +}
> > +if (pass) {
> > +STOP_TIMER("av_dict_get")
> > +} else {
> > +STOP_TIMER("av_dict_set")
> > +}
> > +}
> > +av_dict_free(&dict);
> > +}
> > +#endif
> > 
> >  return 0;
> >  }
> > --
> 
> Hi Michael,
> 
> is av_map_get() supposed tg work? I wasn't able to retrieve any values
> (always null return).

if you flip the #if 0 above this is a test that tests
av_map_get() and other functions.
Its new code and certainly bugs remain.
If you found cases that dont work, send a patch that adds these
cases to this test, and ill look at it eventually
or even better send a patch that fixes the issue you found

thx

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

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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] VP6 Encoder Proposal- Seeking Feedback and Suggestions

2025-04-16 Thread Michael Niedermayer
On Sat, Apr 12, 2025 at 06:48:05PM +0530, SUBHANGANI JHA wrote:
> Hi,
> I'll be elated if you can share the link to the patches.

sorry for the delay:

you should be able to find these in the mailing list archive at ffmpeg or or 
patchworks:

1010 22:45 To FFmpeg devel ( 10K) &─>[FFmpeg-devel] [PATCH 5/5] [RFC] 
libavcodec/ffv1enc: Support storing LSB raw
1016 21:49 To FFmpeg devel (9,7K) &─>[FFmpeg-devel] [PATCH 8/8] 
libavcodec/ffv1: Support storing LSB raw
0307  1:36 To FFmpeg devel ( 14K) [FFmpeg-devel] [PATCH 1/2] libavcodec/ffv1: 
Support storing decorrelated LSB raw without rangecoder

thx

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

What is kyc? Its a tool that makes you give out your real ID, while criminals
give out a forged ID card.


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 v10 2/3] fftools: add mem log flag and disable printing addresses by default

2025-04-16 Thread Michael Niedermayer
Hi

On Thu, Apr 10, 2025 at 08:51:04AM +0200, Nicolas George wrote:
> softworkz (HE12025-04-10):
> > From: softworkz 
> > 
> > This commit adds the mem log flag.
> > When specifying this flag at the command line, context prefixes will
> > be printed with memory addresses like in earlier ffmpeg versions.
> > 
> > Example with mem flag:
> > 
> > [hevc @ 018e72a89cc0] .
> 
> As explained recently, strong opposition to this being the default.

just some random comments:

I think some way to distingish two different "hevc" instances
with high probability should remain.

About the addresses. Iam curious how frequently do people use them ?
and for what exactly ?

I do think *item_name() should be used more often. The "hevc" is a
quite bland identifcation of the instance.

in absence of a item_name(), that is *av_default_item_name()
which prints just the class name. I think printing the address by default
is reasonable otherwsie instances would be always indistingishable

beyond that, i dont remember using the addresses and would not
mind if it gets replaced by something more usefull more repeatable
with maybe some mem flag that could force them to be printed in all
cases

but i dont know, really depends on what the community prefers

thx

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

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway


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 v10 2/3] fftools: add mem log flag and disable printing addresses by default

2025-04-16 Thread Nicolas George
Michael Niedermayer (HE12025-04-16):
> I think some way to distingish two different "hevc" instances
> with high probability should remain.

This is exactly my point. The address is meaningless¹, but it is a sure
way to distinguish instances of the same components without tons of
fragile code.

1: In a debugger, the address would be available without printing.

> I do think *item_name() should be used more often.

Making sure it returns something different for different instances
without the code getting complex and/or the name getting long is quite a
challenge.

This fruit is neither low-hanging nor tasty. My position on this: leave
the address alone unless one has a very good idea to achieve the goal.

Regards,

-- 
  Nicolas George
___
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] fate: add various FFv1 tests for 1024 slices

2025-04-16 Thread Lynne
This lets us test features that were broken earlier, as well as
test the hardware decoder by using the HWACCEL=vulkan option.
---
 tests/Makefile|  1 +
 tests/fate/ffv1.mak   | 46 +++
 tests/ref/fate/ffv1-s1024-bgra|  4 +++
 tests/ref/fate/ffv1-s1024-bgra-r  |  4 +++
 tests/ref/fate/ffv1-s1024-gbrp16  |  4 +++
 tests/ref/fate/ffv1-s1024-gray8   |  4 +++
 tests/ref/fate/ffv1-s1024-gray8-r |  4 +++
 tests/ref/fate/ffv1-s1024-yuv444p |  4 +++
 8 files changed, 71 insertions(+)
 create mode 100644 tests/fate/ffv1.mak
 create mode 100644 tests/ref/fate/ffv1-s1024-bgra
 create mode 100644 tests/ref/fate/ffv1-s1024-bgra-r
 create mode 100644 tests/ref/fate/ffv1-s1024-gbrp16
 create mode 100644 tests/ref/fate/ffv1-s1024-gray8
 create mode 100644 tests/ref/fate/ffv1-s1024-gray8-r
 create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p

diff --git a/tests/Makefile b/tests/Makefile
index f9f5fc07f3..b2386febd7 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -180,6 +180,7 @@ include $(SRC_PATH)/tests/fate/enc_external.mak
 # Must be included after lavf-video.mak
 include $(SRC_PATH)/tests/fate/ffmpeg.mak
 include $(SRC_PATH)/tests/fate/ffprobe.mak
+include $(SRC_PATH)/tests/fate/ffv1.mak
 include $(SRC_PATH)/tests/fate/fifo-muxer.mak
 include $(SRC_PATH)/tests/fate/filter-audio.mak
 # Must be included after vcodec.mak
diff --git a/tests/fate/ffv1.mak b/tests/fate/ffv1.mak
new file mode 100644
index 00..8e1f121e86
--- /dev/null
+++ b/tests/fate/ffv1.mak
@@ -0,0 +1,46 @@
+FATE_FFV1 += fate-ffv1-s1024-gray8
+fate-ffv1-s1024-gray8: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt gray8 -c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gray8-r
+fate-ffv1-s1024-gray8-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt gray8 -c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-yuv444p
+fate-ffv1-s1024-yuv444p: tests/data/vsynth1.yuv
+fate-ffv1-s1024-yuv444p: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt yuv444p -c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra
+fate-ffv1-s1024-bgra: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt bgra -c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra-r
+fate-ffv1-s1024-bgra-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt bgra -c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gbrp16
+fate-ffv1-s1024-gbrp16: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gbrp16: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv420p" tests/data/vsynth1.yuv \
+  nut "-pix_fmt gbrp16 -c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1-$(call FRAMECRC, NUT, FFV1) += $(FATE_FFV1)
+FATE_FFV1_ALL = $(FATE_FFV1-yes)
+FATE_SAMPLES_FFMPEG += $(FATE_FFV1_ALL)
+fate-ffv1: $(FATE_FFV1_ALL)
diff --git a/tests/ref/fate/ffv1-s1024-bgra b/tests/ref/fate/ffv1-s1024-bgra
new file mode 100644
index 00..9d1450c532
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-bgra
@@ -0,0 +1,4 @@
+56a17848398c66ccc7da748b49bc15c6 *tests/data/fate/ffv1-s1024-bgra.nut
+10607302 tests/data/fate/ffv1-s1024-bgra.nut
+a0ead8e9e709b6e93dca3e972a00c3d3 *tests/data/fate/ffv1-s1024-bgra.out.framecrc
+stddev:28285.12 PSNR:  7.30 MAXDIFF:60652 bytes:  7603200/ 2990
diff --git a/tests/ref/fate/ffv1-s1024-bgra-r b/tests/ref/fate/ffv1-s1024-bgra-r
new file mode 100644
index 00..883dc72823
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-bgra-r
@@ -0,0 +1,4 @@
+7040fa7315a9af61b194c140baceb37f *tests/data/fate/ffv1-s1024-bgra-r.nut
+11716414 tests/data/fate/ffv1-s1024-bgra-r.nut
+a0ead8e9e709b6e93dca3e972a00c3d3 
*tests/data/fate/ffv1-s1024-bgra-r.out.framecrc
+stddev:28285.12 PSNR:  7.30 MAXDIFF:60652 bytes:  7603200/ 2990
diff --git a/tests/ref/fate/ffv1-s1024-gbrp16 b/tests/ref/fate/ffv1-s1024-gbrp16
new file mode 100644
index 00..8ec9994a49
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-gbrp16
@@ -0,0 +1,4 @@
+351624f7daa16043baef669fa16222df *tests/data/fate/ffv1-s1024-gbrp16.nut
+40836749 tests/data/fate/ffv1-s1024-gbrp16.nut
+c191aec6b3d999278963ebdd6a326ec3 
*tests/data/fate/ffv1-s1024-gbrp16.out.framecrc
+stddev:28358.70 PSNR:  7.28 MAXDIFF:60652 bytes:  7603200/ 2990
diff --git a/tests/ref/fate/ffv1-s1024-gray8 b/tests/ref/fate/ffv1-s1024-gray8
new file mode 100644
index 00..0f83c2dcac
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-gray8
@@ -0,0 +1,4 @@
+7422502f8d79c69a1081dc4772a2

Re: [FFmpeg-devel] [PATCH 1/3] avutil/dict2: Add AVDictionary2 with hash-based lookup

2025-04-16 Thread Michael Niedermayer
Hi

i like AI and ill reply with more comments about this elsewhere
but as i looked at the code, i had to reply here

[...]

> +/* Get a dictionary entry */
> +AVDictionaryEntry2 *av_dict2_get(const AVDictionary2 *m, const char *key,
> +   const AVDictionaryEntry2 *prev, int flags) {
> +unsigned int hash;
> +int table_idx;
> +DictEntry *entry;
> +
> +static AVDictionaryEntry2 de;  // Return value - holds pointers to 
> internal data
> +
> +if (!m || !key)
> +return NULL;
> +

> +if (prev)
> +return NULL;  // 'prev' functionality not implemented

not implemented ?


> +
> +// Get hash index

> +hash = dict_hash(key, m->flags & AV_DICT2_MATCH_CASE);

case sensitivity is supported by having the set funtiom insert with the
case sensitivity that the get function later will use ?


> +table_idx = hash % m->table_size;
> +
> +// Search in chain
> +for (entry = m->entries[table_idx]; entry; entry = entry->next) {
> +if ((m->flags & AV_DICT2_MATCH_CASE ? 
> + !strcmp(entry->key, key) : 
> + !av_strcasecmp(entry->key, key))) {
> +
> +// Found match
> +de.key = entry->key;
> +de.value = entry->value;
> +return &de;

tasty globals for thread saftey

thx

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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] avutil/map: replace passing Compare functions by flags

2025-04-16 Thread Michael Niedermayer
On Wed, Apr 16, 2025 at 08:22:18PM +, softworkz . wrote:
[...]
>
> That's a good change, because it was in fact confusing.
> 
> Another confusing part of the API is the need for specifying the 
> lengths of key and value - and I finally figured out why it 
> didn't retrieve any elements: those values need to be strlen + 1
> 

> I think the final API should not require any length params
> (or at least it should have a function that doesn't need it)

its there because people asked for support for non string data
ill add a
int av_map_add_strings(AVMap *s, const char *key, const char *value, int flags);

thx

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

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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/3] doc/dict2: Add doc and api change for AVDictionary2

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 23:48
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/3] doc/dict2: Add doc and api
> change for AVDictionary2
> 
> Hi softworkz
> 
> I think we should use AI to support us and reduce the workload
> on people.
> I think this here cost you money and iam not sure this isnt
> adding workload and maybe even increased disagreements between
> people
> 
> can you get AI to do something nooone else is working on ?
> or to support someone on what she is working on. This here
> is a bit more a opposition submission.
> Id love it if AI would submit bugfixes to my code for example
> or if it would submit patches improving my code
> 
> Or maybeit could fix a random ticket chance of collision
> with a human is pretty low
> 
> thx

Was never meant to oppose anything or anybody. Just sent another 
message to hopefully clear this up once and for all. 
I never wanted this job at any point in time. Sorry when this 
hasn't come through clearly enough.

sw


___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Andreas Rheinhardt
Ridley Combs via ffmpeg-devel:
> 
> 
>> On Apr 15, 2025, at 08:59, softworkz .  
>> wrote:
>>
>>
>>
>>> -Original Message-
>>> From: ffmpeg-devel >> > On Behalf Of
>>> Michael Niedermayer
>>> Sent: Dienstag, 15. April 2025 01:20
>>> To: FFmpeg development discussions and patches >> de...@ffmpeg.org >
>>> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
>>> decode_str() did advance
>>>
>>> On Sat, Apr 12, 2025 at 01:49:53AM +, softworkz . wrote:


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Samstag, 12. April 2025 00:27
> To: FFmpeg development discussions and patches >> de...@ffmpeg.org>
> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> decode_str() did advance
>
> Fixes infinite loop with unknown encodings
>
> We could alternatively error out from decode_str() or consume all
>>> of
> taglen
> this would affect other callers though.
>
> Fixes: 409819224/clusterfuzz-testcase-minimized-
>>> ffmpeg_dem_H261_fuzzer-
> 6003527535362048
> Signed-off-by: Michael Niedermayer 
> ---
> libavformat/id3v2.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 90314583a74..e3f7f9e2a90 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -341,10 +341,13 @@ static void read_ttag(AVFormatContext *s,
> AVIOContext *pb, int taglen,
> taglen--; /* account for encoding type byte */
>
> while (taglen > 1) {
> +int current_taglen = taglen;
> if (decode_str(s, pb, encoding, &dst, &taglen) < 0) {
> av_log(s, AV_LOG_ERROR, "Error reading frame %s,
> skipped\n", key);
> return;
> }
> +if (current_taglen == taglen)
> +return;
>
> count++;
>
> --
> 2.49.0
>
> ___

 Hi Michael,

 this kind of conflicts with this patch that I had submitted
>>> recently:


>>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/pull.54.ffstaging.FF
>>> mpeg.1740873449247.ffmpegag...@gmail.com/


 I wonder whether my patch would still be prone to the issue your
>>> patch is addressing -
>>>
>>> This already conflicts with rcombs patch in git master, i think
>>> Applying: Fixes Trac ticket https://trac.ffmpeg.org/ticket/6949
>>> Using index info to reconstruct a base tree...
>>> M   libavformat/id3v2.c
>>> Falling back to patching base and 3-way merge...
>>> Auto-merging libavformat/id3v2.c
>>> CONFLICT (content): Merge conflict in libavformat/id3v2.c
>>> error: Failed to merge in the changes.
>>> Patch failed at 0001 Fixes Trac ticket
>>> https://trac.ffmpeg.org/ticket/6949
>>>
>>>
 do you have a test file perhaps?
>>>
>>> Will email you one, but the loop with a function that doesnt advance
>>> is an issue even if the specific file doesnt trigger it in a different
>>> implementation
>>>
>>> also probaly a good idea if you contact rcombs as you seemed to work
>>> on
>>> the same code
>>>
>>> I was looking at teh ticket and saw a link to rcombs patch, looked at
>>> the patch and applied it. I did not realize there where 2 patches
>>
>>
>> Hi Michael,
>>
>> I know the rcombs patch, but it has a - let's say - different behavior.
>> Let's look at an example where artist and genre have multiple values:
>>
>>
>> This was ffmpeg output unpatched:
>>
>>  Metadata:
>>title   : Infinite (Original Mix)
>>artist  : B-Front
>>track   : 1
>>album   : Infinite
>>date: 2017
>>genre   : Hardstyle
>>TBPM: 150
>>compilation : 0
>>album_artist: B-Front
>>publisher   : Roughstate
>>
>>
>> This is what the rcombs patch does:
>>
>>  Metadata:
>>title   : Infinite (Original Mix)
>>artist  : B-Front
>>artist  : Second Artist Example
>>track   : 1
>>album   : Infinite
>>date: 2017
>>genre   : Hardstyle
>>genre   : Test
>>genre   : Example
>>genre   : Hard Dance
>>TBPM: 150
>>compilation : 0
>>album_artist: B-Front
>>publisher   : Roughstate
>>
>>
>>
>> My path does that:
>>
>>  Metadata:
>>title   : Infinite (Original Mix)
>>artist  : B-Front;Second Artist Example
>>track   : 1
>>album   : Infinite
>>date: 2017
>>genre   : Hardstyle;Test;Example;Hard Dance
>>TBPM: 150
>>compilation : 0
>>album_artist: B-Front
>>publisher   : Roughstate
>>
>>
>>
>> I'm not sure whether it is even allowed or intended that there are 
>>

Re: [FFmpeg-devel] [PATCH v4] libpostproc: deprecate the AMD 3DNow! define

2025-04-16 Thread Andreas Rheinhardt
Sean McGovern:
> It was left unreferenced in 1f0948272a0fcd0e4947f629b600983f3338c02f.
> ---
>  doc/APIchanges  | 3 +++
>  libpostproc/postprocess.h   | 2 ++
>  libpostproc/version.h   | 2 +-
>  libpostproc/version_major.h | 2 ++
>  4 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 65bf5a9419..2236ee1a88 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
>  
>  API changes, most recent first:
>  
> +2025-04-xx - ?? - libpostproc 59.0.101 - postprocess.h
> +  Deprecate PP_CPU_CAPS_3DNOW.
> +
>  2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
>Add AV_DICT_DEDUP.
>  
> diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
> index 5decb7e8a9..d2adb6ccad 100644
> --- a/libpostproc/postprocess.h
> +++ b/libpostproc/postprocess.h
> @@ -87,7 +87,9 @@ void pp_free_context(pp_context *ppContext);
>  
>  #define PP_CPU_CAPS_MMX   0x8000
>  #define PP_CPU_CAPS_MMX2  0x2000
> +#if FF_API_PP_AMD_3DNOW
>  #define PP_CPU_CAPS_3DNOW 0x4000
> +#endif
>  #define PP_CPU_CAPS_ALTIVEC 0x1000
>  #define PP_CPU_CAPS_AUTO  0x0008
>  
> diff --git a/libpostproc/version.h b/libpostproc/version.h
> index bcbdd210c4..de09db989f 100644
> --- a/libpostproc/version.h
> +++ b/libpostproc/version.h
> @@ -31,7 +31,7 @@
>  #include "version_major.h"
>  
>  #define LIBPOSTPROC_VERSION_MINOR   0
> -#define LIBPOSTPROC_VERSION_MICRO 100
> +#define LIBPOSTPROC_VERSION_MICRO 101

minor, not micro

>  
>  #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \
> LIBPOSTPROC_VERSION_MINOR, \
> diff --git a/libpostproc/version_major.h b/libpostproc/version_major.h
> index b40b251a73..b9946912db 100644
> --- a/libpostproc/version_major.h
> +++ b/libpostproc/version_major.h
> @@ -28,4 +28,6 @@
>  
>  #define LIBPOSTPROC_VERSION_MAJOR  59
>  
> +#define FF_API_PP_AMD_3DNOW  (LIBPOSTPROC_VERSION_MAJOR < 60)
> +
>  #endif /* POSTPROC_VERSION_MAJOR_H */

___
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] Request for --disable-deprecated configure option

2025-04-16 Thread Andreas Rheinhardt
Kacper Michajlow:
> On Thu, 3 Apr 2025 at 11:39, Martin Storsjö  wrote:
>>
>> On Thu, 3 Apr 2025, Kacper Michajlow wrote:
>>
>>> Hello,
>>>
>>> It would be nice to have configure time ability to disable all
>>> `FF_API_*` for testing purposes.
>>>
>>> As we know not all code can be marked to emit Wdeprecated.
>>> Specifically #defines doesn't emit any warning and it's easy to miss
>>> such depreciation before it's actually removed.
>>>
>>> The breakage of course is not big, but the main issue is that the
>>> current release version of a ffmpeg user won't be compatible with
>>> ffmpeg after API bump, without any period for transition.
>>>
>>> --disable-deprecated could be used for testing and ensuring that
>>> (next) API bump goes smoothly. For both ffmpeg and its users.
>>
>> So essentially to configure a build to use the next major API version
>> before doing the actual bump?
>>
>> I've actually mentioned that we should do that (and that we should have a
>> FATE instance that continuously tests this, so that we know beforehand
>> that our planned next form of the APIs actually works), and I did try
>> making a PoC of it at some point, but unfortunately, I think I concluded
>> that it was a bit more messy than I had wanted, so I didn't continue
>> on it.
>>
>> See https://github.com/mstorsjo/ffmpeg/commit/next-abi for my PoC.
> 
> Yes, making the API version configurable would work. But as you
> noticed it gets a bit messy with all the conditionals.
> 
> I didn't think about it long, I wanted to discuss this first, but was
> thinking about a simple DISABLE_DEPRECATED which would be defined by
> configure and all `FF_API_*` would depend on that.
> 
> #define DISABLE_DEPRECATED 0
> #define FOO(c) (c) && !DISABLE_DEPRECATED
> 
> #define LIBAVUTIL_VERSION_MAJOR  60
> #define FF_API_MOD_UINTP2   FOO(LIBAVUTIL_VERSION_MAJOR < 61)
> #define FF_API_RISCV_FD_ZBA FOO(LIBAVUTIL_VERSION_MAJOR < 61)
> ...
> 
> Also if someone wants to go fancy, the deprecated feature could be
> disabled individually, but I don't really see much use for that,
> except niche cases where you might still use deprecated things, but
> not all... but then just don't disable them.
> 

This was already possible until db932241ee16868475fe9ab4c958fcffd1829ecf.

- 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 1/2] avcodec/dvbsubenc: Sanity check num_rects

2025-04-16 Thread Andreas Rheinhardt
Patches attached.

- Andreas
From b3a4381000d13ac344114dd5f0230c9eae7b32aa Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Wed, 16 Apr 2025 10:23:01 +0200
Subject: [PATCH 1/2] avcodec/dvbsubenc: Sanity check num_rects
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It is written as region_id which is a single byte.
Also fixes a potential (defined) overflow in the num_rects * 6
multiplication later; this has been found by 김승호 .

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

diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index 822e3a5309..8eeac76855 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -284,6 +284,9 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t *outbuf, int buf_size,
 if (h->num_rects && !h->rects)
 return AVERROR(EINVAL);
 
+if (h->num_rects >= 256)
+return AVERROR_INVALIDDATA;
+
 if (avctx->width > 0 && avctx->height > 0) {
 if (buf_size < 11)
 return AVERROR_BUFFER_TOO_SMALL;
-- 
2.45.2

From c150cc5f4ae4961a56d035b1fdad7c2eb0eccfad Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Wed, 16 Apr 2025 11:03:53 +0200
Subject: [PATCH 2/2] avcodec/dvbsubenc: Check nb_colors before using it

Avoids a potential overflow when multiplying nb_colors by 6.
Also make the nb_colors check a bit more strict.

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

diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
index 8eeac76855..3659e3f9ed 100644
--- a/libavcodec/dvbsubenc.c
+++ b/libavcodec/dvbsubenc.c
@@ -329,24 +329,23 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t *outbuf, int buf_size,
 
 if (h->num_rects) {
 for (clut_id = 0; clut_id < h->num_rects; clut_id++) {
-if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
-return AVERROR_BUFFER_TOO_SMALL;
-
 /* CLUT segment */
 
-if (h->rects[clut_id]->nb_colors <= 4) {
+if (h->rects[clut_id]->nb_colors <= 4U) {
 /* 2 bpp, some decoders do not support it correctly */
 bpp_index = 0;
-} else if (h->rects[clut_id]->nb_colors <= 16) {
+} else if (h->rects[clut_id]->nb_colors <= 16U) {
 /* 4 bpp, standard encoding */
 bpp_index = 1;
-} else if (h->rects[clut_id]->nb_colors <= 256) {
+} else if (h->rects[clut_id]->nb_colors <= 256U) {
 /* 8 bpp, standard encoding */
 bpp_index = 2;
 } else {
 return AVERROR(EINVAL);
 }
 
+if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
+return AVERROR_BUFFER_TOO_SMALL;
 
 /* CLUT segment */
 *q++ = 0x0f; /* sync byte */
-- 
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/2] avcodec/dvbsubenc: Use 64bits in nb_colors and num_rects checks

2025-04-16 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: integer overflow
> 
> No testcase
> 
> Found-by: 김승호 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/dvbsubenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
> index 822e3a53099..53f0f6412fa 100644
> --- a/libavcodec/dvbsubenc.c
> +++ b/libavcodec/dvbsubenc.c
> @@ -302,7 +302,7 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
> *outbuf, int buf_size,
>  
>  /* page composition segment */
>  
> -if (buf_size < 8 + h->num_rects * 6)
> +if (buf_size < 8 + h->num_rects * 6LL)
>  return AVERROR_BUFFER_TOO_SMALL;
>  *q++ = 0x0f; /* sync_byte */
>  *q++ = 0x10; /* segment_type */
> @@ -326,7 +326,7 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
> *outbuf, int buf_size,
>  
>  if (h->num_rects) {
>  for (clut_id = 0; clut_id < h->num_rects; clut_id++) {
> -if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6)
> +if (buf_size < 6 + h->rects[clut_id]->nb_colors * 6LL)
>  return AVERROR_BUFFER_TOO_SMALL;
>  
>  /* CLUT segment */

I just sent different patches for this:
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-April/342314.html
They are intended to make your patches obsolete.

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Nicolas George
softworkz . (HE12025-04-16):
> Please show me widely used implementations which do not break.

No: you are making a strong claim, it is up to you to justify it: prove
that it breaks anything, let alone everything.

-- 
  Nicolas George
___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Nicolas George
softworkz . (HE12025-04-16):
> Does that mean that I can apply any patch from the past few years without
> prior notice when it hasn't received a reply?

Are you already considering abusing your git access?

-- 
  Nicolas George
___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Michael Niedermayer
Hi softworkz

On Wed, Apr 16, 2025 at 02:52:21AM +, softworkz . wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Mittwoch, 16. April 2025 03:34
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > decode_str() did advance
> > 
> > On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
> > [...]
> > > > > This will cause deserialization errors for many people in the
> > world
> > > > > who are processing FFprobe data.
> > > >
> > > > As said, ffprobe should not produce troublesome output
> 
> First of all, any patch MUST NOT introduce behavior that goes
> against our own specifications.
> 
> From avformat.h:
> 
> /**
>  * @defgroup metadata_api Public Metadata API
>  * @{
>  * @ingroup libavf
>  * The metadata API allows libavformat to export metadata tags to a client
>  * application when demuxing. Conversely it allows a client application to
>  * set metadata when muxing.
>  *
>  * Metadata is exported or set as pairs of key/value strings in the 'metadata'
>  * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
>  * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
>  * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
>  * exported by demuxers isn't checked to be valid UTF-8 in most cases.
>  *
>  * Important concepts to keep in mind:
>  * -  Keys are unique; there can never be 2 tags with the same key. This is
>  *also meant semantically, i.e., a demuxer should not knowingly produce
>  *several keys that are literally different but semantically identical.
>  *E.g., key=Author5, key=Author6. In this example, all authors must be
>  *placed in the same tag.
>  * -  Metadata is flat, not hierarchical; there are no subtags. If you
>  *want to store, e.g., the email address of the child of producer Alice
>  *and actor Bob, that could have key=alice_and_bobs_childs_email_address.
>  * -  Several modifiers can be applied to the tag name. This is done by
>  *appending a dash character ('-') and the modifier name in the order
>  *they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
>  *-  language -- a tag whose value is localized for a particular language
>  *   is appended with the ISO 639-2/B 3-letter language code.
>  *   For example: Author-ger=Michael, Author-eng=Mike
>  *   The original/default language is in the unqualified "Author" tag.
>  *   A demuxer should set a default if it sets any translated tag.
>  *-  sorting  -- a modified version of a tag that should be used for
>  *   sorting will have '-sort' appended. E.g. artist="The Beatles",
>  *   artist-sort="Beatles, The".
> 
> 
> Especially:
> 
> *E.g., key=Author5, key=Author6. In this example, all authors must be
> *placed in the same tag.
> 
> I think, this tells very clearly how it's gotta be and how not.

This is written by me 16 years ago
and it made sense at the time. Our APIs did not support multiple values per
key.
The API supports multiple values per key since 9 years. Using said API is
more convenient than having to parse and escape ";" around.
Thats for our code, its simpler for a muxer to iterate over a AVDictionary key
than parse a ";" seperated string (with undefined escaping rules).
and easier to build a ";" string from a multi-value AVDictionary than to assume
the internal ";" escaping rules (whatever they would be) match the target 
format.

commit 47146dfbf6bca94dd0706b4313cc5e26edaf18d4
Author: Michael Niedermayer 
Date:   Sun Jan 4 18:48:37 2009 +

Generic metadata API.
avi is updated as example.
No version bump, the API still might change slightly ...
No update to ffmpeg.c as requested by aurel.

Originally committed as revision 16424 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e45f7d6dfb3..7038d2d2c41 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -400,6 +400,51 @@ enum SampleFormat {
  */
 #define FF_MIN_BUFFER_SIZE 16384

+
+/*
+ * public Metadata API.
+ * Important concepts, to keep in mind
+ * 1. keys are unique, there are never 2 tags with equal keys, this is also
+ *meant semantically that is a demuxer should not knowingly produce
+ *several keys that are litterally different but semantically identical,
+ *like key=Author5, key=Author6.
+ *All authors have to be placed in the same tag for the case of Authors.
+ * 2. Metadata is flat, there are no subtags, if you for whatever obscene
+ *reason want to store the email address of the child of producer alice
+ *and actor bob, that could have key=alice_and_bobs_childs_email_address.
+ * 3. A tag whichs value is translated has the ISO 639 3-letter language code
+ *with a '-' between appended. So for example Author-ger=Michael, 
Author-en

Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Andreas Rheinhardt
Michael Niedermayer:
> Hi softworkz
> 
> On Wed, Apr 16, 2025 at 02:52:21AM +, softworkz . wrote:
>>
>>
>>> -Original Message-
>>> From: ffmpeg-devel  On Behalf Of
>>> Michael Niedermayer
>>> Sent: Mittwoch, 16. April 2025 03:34
>>> To: FFmpeg development discussions and patches >> de...@ffmpeg.org>
>>> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
>>> decode_str() did advance
>>>
>>> On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
>>> [...]
>> This will cause deserialization errors for many people in the
>>> world
>> who are processing FFprobe data.
>
> As said, ffprobe should not produce troublesome output
>>
>> First of all, any patch MUST NOT introduce behavior that goes
>> against our own specifications.
>>
>> From avformat.h:
>>
>> /**
>>  * @defgroup metadata_api Public Metadata API
>>  * @{
>>  * @ingroup libavf
>>  * The metadata API allows libavformat to export metadata tags to a client
>>  * application when demuxing. Conversely it allows a client application to
>>  * set metadata when muxing.
>>  *
>>  * Metadata is exported or set as pairs of key/value strings in the 
>> 'metadata'
>>  * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
>>  * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
>>  * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
>>  * exported by demuxers isn't checked to be valid UTF-8 in most cases.
>>  *
>>  * Important concepts to keep in mind:
>>  * -  Keys are unique; there can never be 2 tags with the same key. This is
>>  *also meant semantically, i.e., a demuxer should not knowingly produce
>>  *several keys that are literally different but semantically identical.
>>  *E.g., key=Author5, key=Author6. In this example, all authors must be
>>  *placed in the same tag.
>>  * -  Metadata is flat, not hierarchical; there are no subtags. If you
>>  *want to store, e.g., the email address of the child of producer Alice
>>  *and actor Bob, that could have key=alice_and_bobs_childs_email_address.
>>  * -  Several modifiers can be applied to the tag name. This is done by
>>  *appending a dash character ('-') and the modifier name in the order
>>  *they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
>>  *-  language -- a tag whose value is localized for a particular language
>>  *   is appended with the ISO 639-2/B 3-letter language code.
>>  *   For example: Author-ger=Michael, Author-eng=Mike
>>  *   The original/default language is in the unqualified "Author" tag.
>>  *   A demuxer should set a default if it sets any translated tag.
>>  *-  sorting  -- a modified version of a tag that should be used for
>>  *   sorting will have '-sort' appended. E.g. artist="The Beatles",
>>  *   artist-sort="Beatles, The".
>>
>>
>> Especially:
>>
>> *E.g., key=Author5, key=Author6. In this example, all authors must be
>> *placed in the same tag.
>>
>> I think, this tells very clearly how it's gotta be and how not.
> 
> This is written by me 16 years ago
> and it made sense at the time. Our APIs did not support multiple values per
> key.
> The API supports multiple values per key since 9 years. Using said API is
> more convenient than having to parse and escape ";" around.
> Thats for our code, its simpler for a muxer to iterate over a AVDictionary key
> than parse a ";" seperated string (with undefined escaping rules).
> and easier to build a ";" string from a multi-value AVDictionary than to 
> assume
> the internal ";" escaping rules (whatever they would be) match the target 
> format.

This is all true, but it does not change that we are bound by our API
guarantees.

> 
> commit 47146dfbf6bca94dd0706b4313cc5e26edaf18d4
> Author: Michael Niedermayer 
> Date:   Sun Jan 4 18:48:37 2009 +
> 
> Generic metadata API.
> avi is updated as example.
> No version bump, the API still might change slightly ...
> No update to ffmpeg.c as requested by aurel.
> 
> Originally committed as revision 16424 to 
> svn://svn.ffmpeg.org/ffmpeg/trunk
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index e45f7d6dfb3..7038d2d2c41 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -400,6 +400,51 @@ enum SampleFormat {
>   */
>  #define FF_MIN_BUFFER_SIZE 16384
> 
> +
> +/*
> + * public Metadata API.
> + * Important concepts, to keep in mind
> + * 1. keys are unique, there are never 2 tags with equal keys, this is also
> + *meant semantically that is a demuxer should not knowingly produce
> + *several keys that are litterally different but semantically identical,
> + *like key=Author5, key=Author6.
> + *All authors have to be placed in the same tag for the case of Authors.
> + * 2. Metadata is flat, there are no subtags, if you for whatever obscene
> + *reason want to store the email address of the child of producer alice
> + 

Re: [FFmpeg-devel] [PATCH v2 04/10] fftools/tf_internal: Use ac_default_item_name

2025-04-16 Thread Andreas Rheinhardt
softworkz:
> From: softworkz 
> 
> Signed-off-by: softworkz 
> ---
>  fftools/textformat/tf_internal.h | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/fftools/textformat/tf_internal.h 
> b/fftools/textformat/tf_internal.h
> index 7b326328cb..e145bc83bb 100644
> --- a/fftools/textformat/tf_internal.h
> +++ b/fftools/textformat/tf_internal.h
> @@ -29,13 +29,9 @@
>  #include "avtextformat.h"
>  
>  #define DEFINE_FORMATTER_CLASS(name)\
> -static const char *name##_get_name(void *ctx)   \
> -{   \
> -return #name ;  \
> -}   \
>  static const AVClass name##_class = {   \
>  .class_name = #name,\
> -.item_name  = name##_get_name,  \
> +.item_name  = av_default_item_name, \
>  .option = name##_options\
>  }
>  

I really don't know why you want to do this yourself instead of just
using my patch.

- Andreas

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 12:53
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> decode_str() did advance
> 
> Hi softworkz
> 
> On Wed, Apr 16, 2025 at 02:52:21AM +, softworkz . wrote:
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Michael Niedermayer
> > > Sent: Mittwoch, 16. April 2025 03:34
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > > decode_str() did advance
> > >
> > > On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
> > > [...]
> > > > > > This will cause deserialization errors for many people in
> the
> > > world
> > > > > > who are processing FFprobe data.
> > > > >
> > > > > As said, ffprobe should not produce troublesome output
> >
> > First of all, any patch MUST NOT introduce behavior that goes
> > against our own specifications.
> >
> > From avformat.h:
> >
> > /**
> >  * @defgroup metadata_api Public Metadata API
> >  * @{
> >  * @ingroup libavf
> >  * The metadata API allows libavformat to export metadata tags to a
> client
> >  * application when demuxing. Conversely it allows a client
> application to
> >  * set metadata when muxing.
> >  *
> >  * Metadata is exported or set as pairs of key/value strings in the
> 'metadata'
> >  * fields of the AVFormatContext, AVStream, AVChapter and AVProgram
> structs
> >  * using the @ref lavu_dict "AVDictionary" API. Like all strings in
> FFmpeg,
> >  * metadata is assumed to be UTF-8 encoded Unicode. Note that
> metadata
> >  * exported by demuxers isn't checked to be valid UTF-8 in most
> cases.
> >  *
> >  * Important concepts to keep in mind:
> >  * -  Keys are unique; there can never be 2 tags with the same key.
> This is
> >  *also meant semantically, i.e., a demuxer should not knowingly
> produce
> >  *several keys that are literally different but semantically
> identical.
> >  *E.g., key=Author5, key=Author6. In this example, all authors
> must be
> >  *placed in the same tag.
> >  * -  Metadata is flat, not hierarchical; there are no subtags. If
> you
> >  *want to store, e.g., the email address of the child of
> producer Alice
> >  *and actor Bob, that could have
> key=alice_and_bobs_childs_email_address.
> >  * -  Several modifiers can be applied to the tag name. This is done
> by
> >  *appending a dash character ('-') and the modifier name in the
> order
> >  *they appear in the list below -- e.g. foo-eng-sort, not foo-
> sort-eng.
> >  *-  language -- a tag whose value is localized for a particular
> language
> >  *   is appended with the ISO 639-2/B 3-letter language code.
> >  *   For example: Author-ger=Michael, Author-eng=Mike
> >  *   The original/default language is in the unqualified
> "Author" tag.
> >  *   A demuxer should set a default if it sets any translated
> tag.
> >  *-  sorting  -- a modified version of a tag that should be used
> for
> >  *   sorting will have '-sort' appended. E.g. artist="The
> Beatles",
> >  *   artist-sort="Beatles, The".
> >
> >
> > Especially:
> >
> > *E.g., key=Author5, key=Author6. In this example, all authors
> must be
> > *placed in the same tag.
> >
> > I think, this tells very clearly how it's gotta be and how not.
> 
> This is written by me 16 years ago
> and it made sense at the time. Our APIs did not support multiple
> values per
> key.
> The API supports multiple values per key since 9 years. Using said API


But it wasn't enabled for metadata, only the recombs patch enabled that, no?

(but, see next message)
sw


___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread softworkz .


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 12:42
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> decode_str() did advance
> 
> On Wed, Apr 16, 2025 at 02:31:58AM +, softworkz . wrote:
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Michael Niedermayer
> > > Sent: Mittwoch, 16. April 2025 03:34
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > > decode_str() did advance
> > >
> > > On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
> > > [...]
> > > > > > This will cause deserialization errors for many people in
> the
> > > world
> > > > > > who are processing FFprobe data.
> > > > >
> > > > > As said, ffprobe should not produce troublesome output
> > > >
> > > > As I said, it cannot be remedied on the FFprobe side without
> making
> > > a
> > >
> > > If you want ffprobe to combine multiple author tags with ";", you
> > > certainly can do that in ffprobe
> >
> > Which by-the-way contradicts most of your earlier arguments against
> > semicolon delimited values.
> 
> does it ?
> 
> 
> >
> > I gain the impression that the actual reason for why you (seemingly)
> > want this, might be for having an actual use case for the duplicate
> key support
> > in AVMap..?  😊
> 
> the AVDictionary struct FFmpeg uses supports multiple
> equal keys since over 9 years:
> commit 4ebf0b109cdb4daa888d69e8294621948168c46c
> Author: Thilo Borgmann 
> Date:   Sat Mar 12 14:52:17 2016 +0100
> 
> lavu/dict: Add new flag to allow multiple equal keys.
> 
> 

Hi Michael,

I think you already know what I would be responding to these things, and it 
might likely become just more repetitive. I feel that I've sufficiently 
expressed my view - maybe even a bit more than I think I should, so I'll step 
back and leave room for others to voice their opinion - if any.

Thanks and nevermind 😊

sw










___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Michael Niedermayer
Hi Andreas

On Wed, Apr 16, 2025 at 12:57:27PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Hi softworkz
> > 
> > On Wed, Apr 16, 2025 at 02:52:21AM +, softworkz . wrote:
> >>
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel  On Behalf Of
> >>> Michael Niedermayer
> >>> Sent: Mittwoch, 16. April 2025 03:34
> >>> To: FFmpeg development discussions and patches  >>> de...@ffmpeg.org>
> >>> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> >>> decode_str() did advance
> >>>
> >>> On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
> >>> [...]
> >> This will cause deserialization errors for many people in the
> >>> world
> >> who are processing FFprobe data.
> >
> > As said, ffprobe should not produce troublesome output
> >>
> >> First of all, any patch MUST NOT introduce behavior that goes
> >> against our own specifications.
> >>
> >> From avformat.h:
> >>
> >> /**
> >>  * @defgroup metadata_api Public Metadata API
> >>  * @{
> >>  * @ingroup libavf
> >>  * The metadata API allows libavformat to export metadata tags to a client
> >>  * application when demuxing. Conversely it allows a client application to
> >>  * set metadata when muxing.
> >>  *
> >>  * Metadata is exported or set as pairs of key/value strings in the 
> >> 'metadata'
> >>  * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
> >>  * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
> >>  * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
> >>  * exported by demuxers isn't checked to be valid UTF-8 in most cases.
> >>  *
> >>  * Important concepts to keep in mind:
> >>  * -  Keys are unique; there can never be 2 tags with the same key. This is
> >>  *also meant semantically, i.e., a demuxer should not knowingly produce
> >>  *several keys that are literally different but semantically identical.
> >>  *E.g., key=Author5, key=Author6. In this example, all authors must be
> >>  *placed in the same tag.
> >>  * -  Metadata is flat, not hierarchical; there are no subtags. If you
> >>  *want to store, e.g., the email address of the child of producer Alice
> >>  *and actor Bob, that could have 
> >> key=alice_and_bobs_childs_email_address.
> >>  * -  Several modifiers can be applied to the tag name. This is done by
> >>  *appending a dash character ('-') and the modifier name in the order
> >>  *they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
> >>  *-  language -- a tag whose value is localized for a particular 
> >> language
> >>  *   is appended with the ISO 639-2/B 3-letter language code.
> >>  *   For example: Author-ger=Michael, Author-eng=Mike
> >>  *   The original/default language is in the unqualified "Author" tag.
> >>  *   A demuxer should set a default if it sets any translated tag.
> >>  *-  sorting  -- a modified version of a tag that should be used for
> >>  *   sorting will have '-sort' appended. E.g. artist="The Beatles",
> >>  *   artist-sort="Beatles, The".
> >>
> >>
> >> Especially:
> >>
> >> *E.g., key=Author5, key=Author6. In this example, all authors must be
> >> *placed in the same tag.
> >>
> >> I think, this tells very clearly how it's gotta be and how not.
> > 
> > This is written by me 16 years ago
> > and it made sense at the time. Our APIs did not support multiple values per
> > key.
> > The API supports multiple values per key since 9 years. Using said API is
> > more convenient than having to parse and escape ";" around.
> > Thats for our code, its simpler for a muxer to iterate over a AVDictionary 
> > key
> > than parse a ";" seperated string (with undefined escaping rules).
> > and easier to build a ";" string from a multi-value AVDictionary than to 
> > assume
> > the internal ";" escaping rules (whatever they would be) match the target 
> > format.
> 
> This is all true, but it does not change that we are bound by our API
> guarantees.

yes, as i said i will revert the patch, iam just a bit behind with what
i want to do and it happening in reality

[...]
-- 
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 2/2] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Michael Niedermayer
On Wed, Apr 16, 2025 at 02:39:44AM +, softworkz . wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Mittwoch, 16. April 2025 02:54
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > decode_str() did advance
> > 
> > On Tue, Apr 15, 2025 at 11:01:14PM +, softworkz . wrote:
> > [...]
> > > Besides, the patch had been submitted 3 years ago, there hasn't been
> > > any review and the merge was totally unexpected.
> > 
> > no reply for 1 week means commit must be expected
> > 
> > "Send a patch to ffmpeg-devel. If no one answers within a reasonable
> >  time-frame (12h for build failures and security fixes, 3 days small
> > changes,
> >  1 week for big patches) then commit your patch if you think it is OK.
> >  Also note, the maintainer can simply ask for more time to review!
> > "
> 
> Does that mean that I can apply any patch from the past few years without
> prior notice when it hasn't received a reply?

you (and everyone else) has my support to review and then apply patches.
we have failed with timely reacting to some patches, so if you want
to pick some up and look into them, that is welcome!

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

"You are 36 times more likely to die in a bathtub than at the hands of a
terrorist. Also, you are 2.5 times more likely to become a president and
2 times more likely to become an astronaut, than to die in a terrorist
attack." -- Thoughty2



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 v2 04/10] fftools/tf_internal: Use ac_default_item_name

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 16. April 2025 12:51
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 04/10] fftools/tf_internal: Use
> ac_default_item_name
> 
> softworkz:
> > From: softworkz 
> >
> > Signed-off-by: softworkz 
> > ---
> >  fftools/textformat/tf_internal.h | 6 +-
> >  1 file changed, 1 insertion(+), 5 deletions(-)
> >
> > diff --git a/fftools/textformat/tf_internal.h
> b/fftools/textformat/tf_internal.h
> > index 7b326328cb..e145bc83bb 100644
> > --- a/fftools/textformat/tf_internal.h
> > +++ b/fftools/textformat/tf_internal.h
> > @@ -29,13 +29,9 @@
> >  #include "avtextformat.h"
> >
> >  #define DEFINE_FORMATTER_CLASS(name)\
> > -static const char *name##_get_name(void *ctx)   \
> > -{   \
> > -return #name ;  \
> > -}   \
> >  static const AVClass name##_class = {   \
> >  .class_name = #name,\
> > -.item_name  = name##_get_name,  \
> > +.item_name  = av_default_item_name, \
> >  .option = name##_options\
> >  }
> >
> 
> I really don't know why you want to do this yourself instead of just
> using my patch.
> 
> - Andreas

I don't understand. Your patch is making changes to the 
DEFINE_FORMATTER_CLASS macro in every single tf_* file.
But these are already consolidate and removed from those
files, so your patch patched something that is removed in 
the new patchset.

What am I missing?

Thanks,
sw

___
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] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread softworkz .


> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 13:07
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> decode_str() did advance
> 
> On Wed, Apr 16, 2025 at 02:39:44AM +, softworkz . wrote:
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Michael Niedermayer
> > > Sent: Mittwoch, 16. April 2025 02:54
> > > To: FFmpeg development discussions and patches  > > de...@ffmpeg.org>
> > > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > > decode_str() did advance
> > >
> > > On Tue, Apr 15, 2025 at 11:01:14PM +, softworkz . wrote:
> > > [...]
> > > > Besides, the patch had been submitted 3 years ago, there hasn't
> been
> > > > any review and the merge was totally unexpected.
> > >
> > > no reply for 1 week means commit must be expected
> > >
> > > "Send a patch to ffmpeg-devel. If no one answers within a
> reasonable
> > >  time-frame (12h for build failures and security fixes, 3 days
> small
> > > changes,
> > >  1 week for big patches) then commit your patch if you think it is
> OK.
> > >  Also note, the maintainer can simply ask for more time to review!
> > > "
> >
> > Does that mean that I can apply any patch from the past few years
> without
> > prior notice when it hasn't received a reply?
> 
> you (and everyone else) has my support to review and then apply
> patches.
> we have failed with timely reacting to some patches, so if you want
> to pick some up and look into them, that is welcome!


Great! (even though it's not what I meant)

Nonetheless, I can assure everybody that I will not apply something 
without posting about it before 😊

sw






___
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] fate: add various FFv1 tests for 1024 slices

2025-04-16 Thread Lynne

On 16/04/2025 12:22, Andreas Rheinhardt wrote:

Lynne:

This lets us test features that were broken earlier, as well as
test the hardware decoder by using the HWACCEL=vulkan option.


Can't you just adjust some of vsynth FFV1 tests to use this many slices?
(Can one even use 1024 slices for such a low resolution?)


I'd rather not. vsynth is the AVCodecContext of tests.
It's a good point to clean up, IMO.


---
  tests/Makefile  |  1 +
  tests/fate/ffv1.mak | 53 +
  tests/ref/fate/ffv1-s1024-bgra  |  4 +++
  tests/ref/fate/ffv1-s1024-bgra-r|  4 +++
  tests/ref/fate/ffv1-s1024-gbrp16|  4 +++
  tests/ref/fate/ffv1-s1024-gray8 |  4 +++
  tests/ref/fate/ffv1-s1024-gray8-r   |  4 +++
  tests/ref/fate/ffv1-s1024-yuv444p   |  4 +++
  tests/ref/fate/ffv1-s1024-yuv444p-r |  4 +++
  9 files changed, 82 insertions(+)
  create mode 100644 tests/fate/ffv1.mak
  create mode 100644 tests/ref/fate/ffv1-s1024-bgra
  create mode 100644 tests/ref/fate/ffv1-s1024-bgra-r
  create mode 100644 tests/ref/fate/ffv1-s1024-gbrp16
  create mode 100644 tests/ref/fate/ffv1-s1024-gray8
  create mode 100644 tests/ref/fate/ffv1-s1024-gray8-r
  create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p
  create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p-r

diff --git a/tests/Makefile b/tests/Makefile
index f9f5fc07f3..b2386febd7 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -180,6 +180,7 @@ include $(SRC_PATH)/tests/fate/enc_external.mak
  # Must be included after lavf-video.mak
  include $(SRC_PATH)/tests/fate/ffmpeg.mak
  include $(SRC_PATH)/tests/fate/ffprobe.mak
+include $(SRC_PATH)/tests/fate/ffv1.mak
  include $(SRC_PATH)/tests/fate/fifo-muxer.mak
  include $(SRC_PATH)/tests/fate/filter-audio.mak
  # Must be included after vcodec.mak
diff --git a/tests/fate/ffv1.mak b/tests/fate/ffv1.mak
new file mode 100644
index 00..16660b5ac2
--- /dev/null
+++ b/tests/fate/ffv1.mak
@@ -0,0 +1,53 @@
+FATE_FFV1 += fate-ffv1-s1024-gray8
+fate-ffv1-s1024-gray8: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \


Seems like you are treating the input file as gray8 (as opposed to
converting it to gray8). Is this intended? Can't this cause problems
because the size of the input file is not necessarily a multiple of the
size expected for a 352x288 gray8 frame?


Shouldn't really cause an issue.
Do you have a better suggestion on how to handle this?


+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gray8-r
+fate-ffv1-s1024-gray8-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-yuv444p
+fate-ffv1-s1024-yuv444p: tests/data/vsynth1.yuv
+fate-ffv1-s1024-yuv444p: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-yuv444p-r
+fate-ffv1-s1024-yuv444p-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-yuv444p-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra
+fate-ffv1-s1024-bgra: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra-r
+fate-ffv1-s1024-bgra-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gbrp16
+fate-ffv1-s1024-gbrp16: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gbrp16: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gbrp16" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""


Won't this test cause issues on BE?


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] [PATCH v2 02/10] fftools/textformat: Quality improvements

2025-04-16 Thread Andreas Rheinhardt
softworkz:
> From: softworkz 
> 
> Signed-off-by: softworkz 
> ---
>  fftools/textformat/avtextformat.c | 111 +++---
>  fftools/textformat/avtextformat.h |   6 +-
>  fftools/textformat/tf_default.c   |   8 ++-
>  fftools/textformat/tf_ini.c   |   2 +-
>  fftools/textformat/tf_json.c  |   8 ++-
>  fftools/textformat/tf_xml.c   |   3 -
>  fftools/textformat/tw_avio.c  |   9 ++-
>  7 files changed, 93 insertions(+), 54 deletions(-)
> 
> diff --git a/fftools/textformat/avtextformat.c 
> b/fftools/textformat/avtextformat.c
> index 811b14b999..4c8def8e65 100644
> --- a/fftools/textformat/avtextformat.c
> +++ b/fftools/textformat/avtextformat.c
> @@ -93,9 +93,8 @@ static const AVClass textcontext_class = {
>  
>  static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
>  {
> -int i;
>  av_bprintf(bp, "0X");
> -for (i = 0; i < ubuf_size; i++)
> +for (unsigned i = 0; i < ubuf_size; i++)
>  av_bprintf(bp, "%02X", ubuf[i]);
>  }
>  
> @@ -141,7 +140,10 @@ int avtext_context_open(AVTextFormatContext  **ptctx,
>  AVTextFormatContext *tctx;
>  int i, ret = 0;
>  
> -if (!(tctx = av_mallocz(sizeof(AVTextFormatContext {
> +if (!ptctx || !formatter)
> +return AVERROR(EINVAL);
> +
> +if (!((tctx = av_mallocz(sizeof(AVTextFormatContext) {
>  ret = AVERROR(ENOMEM);
>  goto fail;
>  }
> @@ -213,25 +215,26 @@ int avtext_context_open(AVTextFormatContext  
> **ptctx,
>  av_log(NULL, AV_LOG_ERROR, " %s", n);
>  av_log(NULL, AV_LOG_ERROR, "\n");
>  }
> -return ret;
> +goto fail;
>  }
>  
>  /* validate replace string */
>  {
> -const uint8_t *p = tctx->string_validation_replacement;
> -const uint8_t *endp = p + strlen(p);
> +const uint8_t *p = (uint8_t *)tctx->string_validation_replacement;
> +const uint8_t *endp = p + strlen((const char *)p);

We use -Wno-pointer-sign in order to avoid these ugly casts.

>  while (*p) {
>  const uint8_t *p0 = p;
>  int32_t code;
>  ret = av_utf8_decode(&code, &p, endp, 
> tctx->string_validation_utf8_flags);
>  if (ret < 0) {
>  AVBPrint bp;
> -av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
> +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
>  bprint_bytes(&bp, p0, p - p0),
>  av_log(tctx, AV_LOG_ERROR,
> "Invalid UTF8 sequence %s found in string 
> validation replace '%s'\n",
> bp.str, tctx->string_validation_replacement);
> -return ret;
> +av_bprint_finalize(&bp, NULL);

You know that this is supposed to be for a single UTF-8 code point? It
is not supposed to write hundreds of bytes (although this may happen
with crazy input).

> +goto fail;
>  }
>  }
>  }
> @@ -259,6 +262,9 @@ static const char unit_bit_per_second_str[] = "bit/s";
>  
>  void avtext_print_section_header(AVTextFormatContext *tctx, const void 
> *data, int section_id)
>  {
> +if (section_id < 0 || section_id >= tctx->nb_sections)
> +return;
> +
>  tctx->level++;
>  av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);
>  
> @@ -272,6 +278,9 @@ void avtext_print_section_header(AVTextFormatContext 
> *tctx, const void *data, in
>  
>  void avtext_print_section_footer(AVTextFormatContext *tctx)
>  {
> +if (tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
> +return;
> +
>  int section_id = tctx->section[tctx->level]->id;
>  int parent_section_id = tctx->level
>  ? tctx->section[tctx->level - 1]->id
> @@ -289,7 +298,12 @@ void avtext_print_section_footer(AVTextFormatContext 
> *tctx)
>  
>  void avtext_print_integer(AVTextFormatContext *tctx, const char *key, 
> int64_t val)
>  {
> -const struct AVTextFormatSection *section = tctx->section[tctx->level];
> +const AVTextFormatSection *section;
> +
> +if (!key || tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
> +return;
> +
> +section = tctx->section[tctx->level];
>  
>  if (section->show_all_entries || av_dict_get(section->entries_to_show, 
> key, NULL, 0)) {
>  tctx->formatter->print_integer(tctx, key, val);
> @@ -299,24 +313,25 @@ void avtext_print_integer(AVTextFormatContext *tctx, 
> const char *key, int64_t va
>  
>  static inline int validate_string(AVTextFormatContext *tctx, char **dstp, 
> const char *src)
>  {
> -const uint8_t *p, *endp;
> +const uint8_t *p, *endp, *srcp = (const uint8_t *)src;
>  AVBPrint dstbuf;
> +AVBPrint bp;
>  int invalid_chars_nb = 0, ret = 0;
>  
> +*dstp = NULL;
>  av_bprint_init(&dstbuf, 0, AV_BPRINT_SIZE_UNLIMITED);
> +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
>  
> -endp = src +

Re: [FFmpeg-devel] [PATCH 2/9] fftools/textformat: Quality improvements

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Dienstag, 15. April 2025 03:06
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 2/9] fftools/textformat: Quality
> improvements
> 
> softworkz:
> > From: softworkz 
> >
> > Signed-off-by: softworkz 
> > ---
> >  fftools/textformat/avtextformat.c | 121 +++
> ---
> >  fftools/textformat/avtextformat.h |   6 +-
> >  fftools/textformat/tf_default.c   |   8 +-
> >  fftools/textformat/tf_ini.c   |   2 +-
> >  fftools/textformat/tf_json.c  |   8 +-
> >  fftools/textformat/tf_xml.c   |   3 -
> >  fftools/textformat/tw_avio.c  |   9 ++-
> >  7 files changed, 101 insertions(+), 56 deletions(-)
> >
> > diff --git a/fftools/textformat/avtextformat.c
> b/fftools/textformat/avtextformat.c
> > index 1ce51d11e2..406025d19d 100644
> > --- a/fftools/textformat/avtextformat.c
> > +++ b/fftools/textformat/avtextformat.c
> > @@ -93,9 +93,8 @@ static const AVClass textcontext_class = {
> >
> >  static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t
> ubuf_size)
> >  {
> > -int i;
> >  av_bprintf(bp, "0X");
> > -for (i = 0; i < ubuf_size; i++)
> > +for (unsigned i = 0; i < ubuf_size; i++)
> 
> Why not size_t?
> 
> >  av_bprintf(bp, "%02X", ubuf[i]);
> >  }
> >
> > @@ -110,8 +109,6 @@ int avtext_context_close(AVTextFormatContext
> **ptctx)
> >
> >  av_hash_freep(&tctx->hash);
> >
> > -av_hash_freep(&tctx->hash);
> > -
> >  if (tctx->formatter->uninit)
> >  tctx->formatter->uninit(tctx);
> >  for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
> > @@ -141,12 +138,18 @@ int avtext_context_open(AVTextFormatContext
> **ptctx,
> >  AVTextFormatContext *tctx;
> >  int i, ret = 0;
> >
> > -if (!(tctx = av_mallocz(sizeof(AVTextFormatContext {
> > +if (!ptctx || !formatter)
> > +return AVERROR(EINVAL);
> 
> Can this happen?
> 
> > +
> > +if (!formatter->priv_size && formatter->priv_class)
> > +return AVERROR(EINVAL);
> 
> Stuff like this should never happen and should not be checked (or
> actually: the proper place to check stuff like this is in test tools
> like lavc/tests/avcodec.c, but I don't think it is worth it for
> fftools).
> 
> > +
> > +if (!((tctx = av_mallocz(sizeof(AVTextFormatContext) {
> >  ret = AVERROR(ENOMEM);
> >  goto fail;
> >  }
> >
> > -if (!(tctx->priv = av_mallocz(formatter->priv_size))) {
> > +if (formatter->priv_size && !((tctx->priv =
> av_mallocz(formatter->priv_size {
> >  ret = AVERROR(ENOMEM);
> >  goto fail;
> >  }
> > @@ -215,15 +218,15 @@ int avtext_context_open(AVTextFormatContext
> **ptctx,
> >
> >  /* validate replace string */
> >  {
> > -const uint8_t *p = tctx->string_validation_replacement;
> > -const uint8_t *endp = p + strlen(p);
> > +const uint8_t *p = (uint8_t *)tctx-
> >string_validation_replacement;
> > +const uint8_t *endp = p + strlen((const char *)p);
> >  while (*p) {
> >  const uint8_t *p0 = p;
> >  int32_t code;
> >  ret = av_utf8_decode(&code, &p, endp, tctx-
> >string_validation_utf8_flags);
> >  if (ret < 0) {
> >  AVBPrint bp;
> > -av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
> > +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
> 
> This adds a memleak on data where it makes a difference.
> 
> >  bprint_bytes(&bp, p0, p - p0),
> >  av_log(tctx, AV_LOG_ERROR,
> > "Invalid UTF8 sequence %s found in
> string validation replace '%s'\n",
> > @@ -259,6 +262,9 @@ static const char unit_bit_per_second_str[] =
> "bit/s";
> >
> >  void avtext_print_section_header(AVTextFormatContext *tctx, const
> void *data, int section_id)
> >  {
> > +if (!tctx || section_id < 0 || section_id >= tctx->nb_sections)
> > +return;
> 
> Can this happen?
> 
> > +
> >  tctx->level++;
> >  av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);
> >
> > @@ -272,6 +278,9 @@ void
> avtext_print_section_header(AVTextFormatContext *tctx, const void
> *data, in
> >
> >  void avtext_print_section_footer(AVTextFormatContext *tctx)
> >  {
> > +if (!tctx || tctx->level < 0 || tctx->level >=
> SECTION_MAX_NB_LEVELS)
> > +return;
> 
> Can this happen?
> 
> > +
> >  int section_id = tctx->section[tctx->level]->id;
> >  int parent_section_id = tctx->level
> >  ? tctx->section[tctx->level - 1]->id
> > @@ -289,7 +298,12 @@ void
> avtext_print_section_footer(AVTextFormatContext *tctx)
> >
> >  void avtext_print_integer(AVTextFormatContext *tctx, const char
> *key, int64_t val)
> >  {
> > -const struct AVTextFormatSection *section = tctx->section[tctx-
> >level];
> > +const AVTextFormatSection *section;
> > +
> > +if (!tctx || !key || tctx->level < 0 || tctx->level >=

[FFmpeg-devel] [PATCH] fate: add various FFv1 tests for 1024 slices

2025-04-16 Thread Lynne
This lets us test features that were broken earlier, as well as
test the hardware decoder by using the HWACCEL=vulkan option.
---
 tests/Makefile  |  1 +
 tests/fate/ffv1.mak | 53 +
 tests/ref/fate/ffv1-s1024-bgra  |  4 +++
 tests/ref/fate/ffv1-s1024-bgra-r|  4 +++
 tests/ref/fate/ffv1-s1024-gbrp16|  4 +++
 tests/ref/fate/ffv1-s1024-gray8 |  4 +++
 tests/ref/fate/ffv1-s1024-gray8-r   |  4 +++
 tests/ref/fate/ffv1-s1024-yuv444p   |  4 +++
 tests/ref/fate/ffv1-s1024-yuv444p-r |  4 +++
 9 files changed, 82 insertions(+)
 create mode 100644 tests/fate/ffv1.mak
 create mode 100644 tests/ref/fate/ffv1-s1024-bgra
 create mode 100644 tests/ref/fate/ffv1-s1024-bgra-r
 create mode 100644 tests/ref/fate/ffv1-s1024-gbrp16
 create mode 100644 tests/ref/fate/ffv1-s1024-gray8
 create mode 100644 tests/ref/fate/ffv1-s1024-gray8-r
 create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p
 create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p-r

diff --git a/tests/Makefile b/tests/Makefile
index f9f5fc07f3..b2386febd7 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -180,6 +180,7 @@ include $(SRC_PATH)/tests/fate/enc_external.mak
 # Must be included after lavf-video.mak
 include $(SRC_PATH)/tests/fate/ffmpeg.mak
 include $(SRC_PATH)/tests/fate/ffprobe.mak
+include $(SRC_PATH)/tests/fate/ffv1.mak
 include $(SRC_PATH)/tests/fate/fifo-muxer.mak
 include $(SRC_PATH)/tests/fate/filter-audio.mak
 # Must be included after vcodec.mak
diff --git a/tests/fate/ffv1.mak b/tests/fate/ffv1.mak
new file mode 100644
index 00..16660b5ac2
--- /dev/null
+++ b/tests/fate/ffv1.mak
@@ -0,0 +1,53 @@
+FATE_FFV1 += fate-ffv1-s1024-gray8
+fate-ffv1-s1024-gray8: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gray8-r
+fate-ffv1-s1024-gray8-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gray8-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-yuv444p
+fate-ffv1-s1024-yuv444p: tests/data/vsynth1.yuv
+fate-ffv1-s1024-yuv444p: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-yuv444p-r
+fate-ffv1-s1024-yuv444p-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-yuv444p-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra
+fate-ffv1-s1024-bgra: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-bgra-r
+fate-ffv1-s1024-bgra-r: tests/data/vsynth1.yuv
+fate-ffv1-s1024-bgra-r: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
+  framecrc "" ""
+
+FATE_FFV1 += fate-ffv1-s1024-gbrp16
+fate-ffv1-s1024-gbrp16: tests/data/vsynth1.yuv
+fate-ffv1-s1024-gbrp16: CMD = enc_dec \
+  "rawvideo -s 352x288 -pix_fmt gbrp16" tests/data/vsynth1.yuv \
+  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
+  framecrc "" ""
+
+FATE_FFV1-$(call ENCDEC, FFV1, NUT) += $(FATE_FFV1)
+FATE_FFV1_ALL = $(FATE_FFV1-yes)
+FATE_SAMPLES_FFMPEG += $(FATE_FFV1_ALL)
+fate-ffv1: $(FATE_FFV1_ALL)
diff --git a/tests/ref/fate/ffv1-s1024-bgra b/tests/ref/fate/ffv1-s1024-bgra
new file mode 100644
index 00..9e8ecb0d17
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-bgra
@@ -0,0 +1,4 @@
+b5374eb750c4eb58be89e56adba70294 *tests/data/fate/ffv1-s1024-bgra.nut
+5952517 tests/data/fate/ffv1-s1024-bgra.nut
+5a62bfcd55a764b27412ff4aa710d43a *tests/data/fate/ffv1-s1024-bgra.out.framecrc
+stddev:28579.81 PSNR:  7.21 MAXDIFF:60652 bytes:  7603200/ 1134
diff --git a/tests/ref/fate/ffv1-s1024-bgra-r b/tests/ref/fate/ffv1-s1024-bgra-r
new file mode 100644
index 00..6432fc11c5
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-bgra-r
@@ -0,0 +1,4 @@
+7d4a469b945db6a6a0020390742cfed0 *tests/data/fate/ffv1-s1024-bgra-r.nut
+7393681 tests/data/fate/ffv1-s1024-bgra-r.nut
+5a62bfcd55a764b27412ff4aa710d43a 
*tests/data/fate/ffv1-s1024-bgra-r.out.framecrc
+stddev:28579.81 PSNR:  7.21 MAXDIFF:60652 bytes:  7603200/ 1134
diff --git a/tests/ref/fate/ffv1-s1024-gbrp16 b/tests/ref/fate/ffv1-s1024-gbrp16
new file mode 100644
index 00..182d969afa
--- /dev/null
+++ b/tests/ref/fate/ffv1-s1024-gbrp16
@@ -0,0 +1,4 @@
+0da1f15bc7dbfb960cbb37b7554b9fd4 *tests/data/fate/ffv1-s1024-gbrp16.nut
+9611659 tests/data/fate/ffv1-s1024-gbrp16.nut
+40d9a119d8571e60e7bcd453ad211ca8 
*tests/data/fate/ffv1-s1024-gbrp16.out.framecrc
+stddev:28754.8

Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that decode_str() did advance

2025-04-16 Thread Michael Niedermayer
On Wed, Apr 16, 2025 at 02:31:58AM +, softworkz . wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Michael Niedermayer
> > Sent: Mittwoch, 16. April 2025 03:34
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/id3v2: Check that
> > decode_str() did advance
> > 
> > On Wed, Apr 16, 2025 at 01:29:02AM +, softworkz . wrote:
> > [...]
> > > > > This will cause deserialization errors for many people in the
> > world
> > > > > who are processing FFprobe data.
> > > >
> > > > As said, ffprobe should not produce troublesome output
> > >
> > > As I said, it cannot be remedied on the FFprobe side without making
> > a
> > 
> > If you want ffprobe to combine multiple author tags with ";", you
> > certainly can do that in ffprobe
> 
> Which by-the-way contradicts most of your earlier arguments against
> semicolon delimited values.

does it ?


> 
> I gain the impression that the actual reason for why you (seemingly)
> want this, might be for having an actual use case for the duplicate key 
> support
> in AVMap..?  😊

the AVDictionary struct FFmpeg uses supports multiple
equal keys since over 9 years:

commit 4ebf0b109cdb4daa888d69e8294621948168c46c
Author: Thilo Borgmann 
Date:   Sat Mar 12 14:52:17 2016 +0100

lavu/dict: Add new flag to allow multiple equal keys.


thx

[...]
-- 
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 v2 02/10] fftools/textformat: Quality improvements

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Mittwoch, 16. April 2025 12:49
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 02/10] fftools/textformat:
> Quality improvements
> 
> softworkz:
> > From: softworkz 
> >
> > Signed-off-by: softworkz 
> > ---
> >  fftools/textformat/avtextformat.c | 111 +++
> ---
> >  fftools/textformat/avtextformat.h |   6 +-
> >  fftools/textformat/tf_default.c   |   8 ++-
> >  fftools/textformat/tf_ini.c   |   2 +-
> >  fftools/textformat/tf_json.c  |   8 ++-
> >  fftools/textformat/tf_xml.c   |   3 -
> >  fftools/textformat/tw_avio.c  |   9 ++-
> >  7 files changed, 93 insertions(+), 54 deletions(-)
> >
> > diff --git a/fftools/textformat/avtextformat.c
> b/fftools/textformat/avtextformat.c
> > index 811b14b999..4c8def8e65 100644
> > --- a/fftools/textformat/avtextformat.c
> > +++ b/fftools/textformat/avtextformat.c
> > @@ -93,9 +93,8 @@ static const AVClass textcontext_class = {
> >
> >  static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t
> ubuf_size)
> >  {
> > -int i;
> >  av_bprintf(bp, "0X");
> > -for (i = 0; i < ubuf_size; i++)
> > +for (unsigned i = 0; i < ubuf_size; i++)
> >  av_bprintf(bp, "%02X", ubuf[i]);
> >  }
> >
> > @@ -141,7 +140,10 @@ int avtext_context_open(AVTextFormatContext
> **ptctx,
> >  AVTextFormatContext *tctx;
> >  int i, ret = 0;
> >
> > -if (!(tctx = av_mallocz(sizeof(AVTextFormatContext {
> > +if (!ptctx || !formatter)
> > +return AVERROR(EINVAL);
> > +
> > +if (!((tctx = av_mallocz(sizeof(AVTextFormatContext) {
> >  ret = AVERROR(ENOMEM);
> >  goto fail;
> >  }
> > @@ -213,25 +215,26 @@ int avtext_context_open(AVTextFormatContext
> **ptctx,
> >  av_log(NULL, AV_LOG_ERROR, " %s", n);
> >  av_log(NULL, AV_LOG_ERROR, "\n");
> >  }
> > -return ret;
> > +goto fail;
> >  }
> >
> >  /* validate replace string */
> >  {
> > -const uint8_t *p = tctx->string_validation_replacement;
> > -const uint8_t *endp = p + strlen(p);
> > +const uint8_t *p = (uint8_t *)tctx-
> >string_validation_replacement;
> > +const uint8_t *endp = p + strlen((const char *)p);
> 
> We use -Wno-pointer-sign in order to avoid these ugly casts.

Yep, I know. Since I'm not a C-for-life developer, I'm using and 
taking attention of warnings and hints like clang-tidy.
When you have a file with dozens of warnings these things are not
helpful, because you cannot go through all of them a hundred times.
When disabling certain warnings altogether, nothing is won, because
often there's one in ten cases where the it hints at a problem while
all others are harmless. 
In order to get rid of a warning, you can either add ugly comments 
or - the designated way from the compiler side is to be explicit by
e.g. making explicit casts. That's why you see them at some places.
Doing so, improves quality when working - even for languages that 
I know in a similar way like you know C.

If we could agree to remove these in a future commit, it would be 
great. Otherwise, I can drop them right now as well.


> 
> >  while (*p) {
> >  const uint8_t *p0 = p;
> >  int32_t code;
> >  ret = av_utf8_decode(&code, &p, endp, tctx-
> >string_validation_utf8_flags);
> >  if (ret < 0) {
> >  AVBPrint bp;
> > -av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
> > +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
> >  bprint_bytes(&bp, p0, p - p0),
> >  av_log(tctx, AV_LOG_ERROR,
> > "Invalid UTF8 sequence %s found in
> string validation replace '%s'\n",
> > bp.str, tctx-
> >string_validation_replacement);
> > -return ret;
> > +av_bprint_finalize(&bp, NULL);
> 
> You know that this is supposed to be for a single UTF-8 code point? It
> is not supposed to write hundreds of bytes (although this may happen
> with crazy input).
> 
> > +goto fail;
> >  }
> >  }
> >  }
> > @@ -259,6 +262,9 @@ static const char unit_bit_per_second_str[] =
> "bit/s";
> >
> >  void avtext_print_section_header(AVTextFormatContext *tctx, const
> void *data, int section_id)
> >  {
> > +if (section_id < 0 || section_id >= tctx->nb_sections)
> > +return;
> > +
> >  tctx->level++;
> >  av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);
> >
> > @@ -272,6 +278,9 @@ void
> avtext_print_section_header(AVTextFormatContext *tctx, const void
> *data, in
> >
> >  void avtext_print_section_footer(AVTextFormatContext *tctx)
> >  {
> > +if (tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
> > +return;
> > +
> >  int section_id = tctx->sec

[FFmpeg-devel] [PATCH v2 01/10] fftools/textformat: Formatting and whitespace changes

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 fftools/textformat/avtextformat.c  | 104 +++--
 fftools/textformat/avtextformat.h  |  16 ++---
 fftools/textformat/avtextwriters.h |  11 ++-
 fftools/textformat/tf_compact.c|  91 ++---
 fftools/textformat/tf_default.c|  20 +++---
 fftools/textformat/tf_flat.c   |  26 
 fftools/textformat/tf_ini.c|  36 +-
 fftools/textformat/tf_json.c   |  10 +--
 fftools/textformat/tf_xml.c|  30 +
 9 files changed, 183 insertions(+), 161 deletions(-)

diff --git a/fftools/textformat/avtextformat.c 
b/fftools/textformat/avtextformat.c
index 44085fc87a..811b14b999 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -34,9 +34,9 @@
 #include "libavutil/opt.h"
 #include "avtextformat.h"
 
-#define SECTION_ID_NONE -1
+#define SECTION_ID_NONE (-1)
 
-#define SHOW_OPTIONAL_FIELDS_AUTO   -1
+#define SHOW_OPTIONAL_FIELDS_AUTO  (-1)
 #define SHOW_OPTIONAL_FIELDS_NEVER   0
 #define SHOW_OPTIONAL_FIELDS_ALWAYS  1
 
@@ -64,14 +64,14 @@ static const char *textcontext_get_formatter_name(void *p)
 
 static const AVOption textcontext_options[] = {
 { "string_validation", "set string validation mode",
-  OFFSET(string_validation), AV_OPT_TYPE_INT, 
{.i64=AV_TEXTFORMAT_STRING_VALIDATION_REPLACE}, 0, 
AV_TEXTFORMAT_STRING_VALIDATION_NB-1, .unit = "sv" },
+  OFFSET(string_validation), AV_OPT_TYPE_INT, { .i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE }, 0, 
AV_TEXTFORMAT_STRING_VALIDATION_NB - 1, .unit = "sv" },
 { "sv", "set string validation mode",
-  OFFSET(string_validation), AV_OPT_TYPE_INT, 
{.i64=AV_TEXTFORMAT_STRING_VALIDATION_REPLACE}, 0, 
AV_TEXTFORMAT_STRING_VALIDATION_NB-1, .unit = "sv" },
-{ "ignore",  NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_IGNORE},  .unit = "sv" },
-{ "replace", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE}, .unit = "sv" },
-{ "fail",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_FAIL},.unit = "sv" },
-{ "string_validation_replacement", "set string validation replacement 
string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, {.str=""}},
-{ "svr", "set string validation replacement string", 
OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, 
{.str="\xEF\xBF\xBD"}},
+  OFFSET(string_validation), AV_OPT_TYPE_INT, { .i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE }, 0, 
AV_TEXTFORMAT_STRING_VALIDATION_NB - 1, .unit = "sv" },
+{ "ignore",  NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_IGNORE },  .unit = "sv" },
+{ "replace", NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_REPLACE }, .unit = "sv" },
+{ "fail",NULL, 0, AV_OPT_TYPE_CONST,  { .i64 = 
AV_TEXTFORMAT_STRING_VALIDATION_FAIL },.unit = "sv" },
+{ "string_validation_replacement", "set string validation replacement 
string", OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, { .str = "" 
} },
+{ "svr", "set string validation replacement string", 
OFFSET(string_validation_replacement), AV_OPT_TYPE_STRING, { .str = 
"\xEF\xBF\xBD" } },
 { NULL }
 };
 
@@ -125,14 +125,18 @@ void avtext_context_close(AVTextFormatContext **ptctx)
 }
 
 
-int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter 
*formatter, AVTextWriterContext *writer_context, const char *args,
-const struct AVTextFormatSection *sections, int 
nb_sections,
-int show_value_unit,
-int use_value_prefix,
-int use_byte_value_binary_prefix,
-int use_value_sexagesimal_format,
-int show_optional_fields,
-char *show_data_hash)
+int avtext_context_open(AVTextFormatContext  **ptctx,
+const AVTextFormatter *formatter,
+AVTextWriterContext   *writer_context,
+const char*args,
+const AVTextFormatSection *sections,
+intnb_sections,
+intshow_value_unit,
+intuse_value_prefix,
+int
use_byte_value_binary_prefix,
+int
use_value_sexagesimal_format,
+intshow_optional_fields,
+char  *show_data_hash)
 {
 AVTextFormatContext *tctx;
 int i, ret = 0;
@@ -200,7 +204,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const 
AVTextFormatter *form
 av_dict_free(&opts);
 }
 
-if (show_data_hash) {
+if (sho

[FFmpeg-devel] [PATCH v2 00/10] Execution Graph Printing

2025-04-16 Thread ffmpegagent
Shortest cover letter for my longest-running FFmpeg patchset:

 * Apply
 * Build
 * Add the "-sg" switch to any FFmpeg command line
 * Press 'q' when you don't want to wait

SG = Show Graph

Documentation and examples can be found here:

https://github.com/softworkz/ffmpeg_output_apis/wiki


Version Updates
===


V2
==

 * Rebased on top of Andreas' improvements
 * Applied changes from review (thanks, Andreas)

softworkz (10):
  fftools/textformat: Formatting and whitespace changes
  fftools/textformat: Quality improvements
  fftools/textformat: Introduce common header and deduplicate code
  fftools/tf_internal: Use ac_default_item_name
  fftools/textformat: Add function avtext_print_integer_flags()
  fftools/ffmpeg_filter: Move some declaration to new header file
  avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx()
  fftools/resources: Add resource manager files
  fftools/graphprint: Add execution graph printing
  fftools/graphprint: Now, make it a Killer-Feature!

 doc/APIchanges |3 +
 doc/ffmpeg.texi|   14 +
 ffbuild/common.mak |   28 +-
 fftools/Makefile   |   18 +
 fftools/ffmpeg.c   |4 +
 fftools/ffmpeg.h   |4 +
 fftools/ffmpeg_filter.c|  195 +
 fftools/ffmpeg_filter.h|  234 ++
 fftools/ffmpeg_opt.c   |   17 +
 fftools/graph/filelauncher.c   |  204 +
 fftools/graph/graphprint.c | 1146 
 fftools/graph/graphprint.h |   62 ++
 fftools/resources/.gitignore   |4 +
 fftools/resources/Makefile |   27 +
 fftools/resources/graph.css|  353 +
 fftools/resources/graph.html   |   86 +++
 fftools/resources/resman.c |  213 ++
 fftools/resources/resman.h |   50 ++
 fftools/textformat/avtextformat.c  |  238 +++---
 fftools/textformat/avtextformat.h  |   53 +-
 fftools/textformat/avtextwriters.h |   11 +-
 fftools/textformat/tf_compact.c|  121 +--
 fftools/textformat/tf_default.c|   55 +-
 fftools/textformat/tf_flat.c   |   51 +-
 fftools/textformat/tf_ini.c|   62 +-
 fftools/textformat/tf_internal.h   |   81 ++
 fftools/textformat/tf_json.c   |   56 +-
 fftools/textformat/tf_mermaid.c|  655 
 fftools/textformat/tf_mermaid.h|   41 +
 fftools/textformat/tf_xml.c|   68 +-
 fftools/textformat/tw_avio.c   |   16 +-
 fftools/textformat/tw_buffer.c |7 +-
 fftools/textformat/tw_stdout.c |8 +-
 libavfilter/avfilter.c |9 +
 libavfilter/avfilter.h |   12 +
 35 files changed, 3662 insertions(+), 544 deletions(-)
 create mode 100644 fftools/ffmpeg_filter.h
 create mode 100644 fftools/graph/filelauncher.c
 create mode 100644 fftools/graph/graphprint.c
 create mode 100644 fftools/graph/graphprint.h
 create mode 100644 fftools/resources/.gitignore
 create mode 100644 fftools/resources/Makefile
 create mode 100644 fftools/resources/graph.css
 create mode 100644 fftools/resources/graph.html
 create mode 100644 fftools/resources/resman.c
 create mode 100644 fftools/resources/resman.h
 create mode 100644 fftools/textformat/tf_internal.h
 create mode 100644 fftools/textformat/tf_mermaid.c
 create mode 100644 fftools/textformat/tf_mermaid.h


base-commit: a888975a3c25760027cd59932f5c1ad04368db8b
Published-As: 
https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging-66%2Fsoftworkz%2Fsubmit_print_execution_graph-v2
Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg 
pr-ffstaging-66/softworkz/submit_print_execution_graph-v2
Pull-Request: https://github.com/ffstaging/FFmpeg/pull/66

Range-diff vs v1:

  1:  3df2018c81 !  1:  b6468d1a30 fftools/textformat: Formatting and 
whitespace changes
 @@ fftools/textformat/avtextformat.c: static const char 
*textcontext_get_formatter_
   { NULL }
   };
   
 -@@ fftools/textformat/avtextformat.c: int 
avtext_context_close(AVTextFormatContext **ptctx)
 +@@ fftools/textformat/avtextformat.c: void 
avtext_context_close(AVTextFormatContext **ptctx)
   }
   
   
 @@ fftools/textformat/avtextformat.c: int 
avtext_print_string(AVTextFormatContext *
  - const char *key, AVRational q, 
char sep)
  +void avtext_print_rational(AVTextFormatContext *tctx, const char *key, 
AVRational q, char sep)
   {
 - AVBPrint buf;
 - av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
 + char buf[44];
 + snprintf(buf, sizeof(buf), "%d%c%d", q.num, sep, q.den);
  @@ fftools/textformat/avtextformat.c: void 
avtext_print_rational(AVTextFormatContext *tctx,
   }
   
  2:  04cce91500 !  2:  6568269678 fftools/textformat: Quality improvements
 @@ fftools/textformat/avtextformat.c: static const AVClass 
textcontext_class = {
   av_bprintf(bp, "%02X", ubuf[i]);
   }
   
 -@@ f

[FFmpeg-devel] [PATCH v2 03/10] fftools/textformat: Introduce common header and deduplicate code

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 fftools/textformat/avtextwriters.h |  2 +-
 fftools/textformat/tf_compact.c| 32 ---
 fftools/textformat/tf_default.c| 27 +++---
 fftools/textformat/tf_flat.c   | 25 +++--
 fftools/textformat/tf_ini.c| 24 +++--
 fftools/textformat/tf_internal.h   | 85 ++
 fftools/textformat/tf_json.c   | 38 +
 fftools/textformat/tf_xml.c| 35 +---
 fftools/textformat/tw_avio.c   |  9 ++--
 fftools/textformat/tw_buffer.c |  7 +--
 fftools/textformat/tw_stdout.c |  8 +--
 11 files changed, 150 insertions(+), 142 deletions(-)
 create mode 100644 fftools/textformat/tf_internal.h

diff --git a/fftools/textformat/avtextwriters.h 
b/fftools/textformat/avtextwriters.h
index 34db3f1832..fd6da747eb 100644
--- a/fftools/textformat/avtextwriters.h
+++ b/fftools/textformat/avtextwriters.h
@@ -41,7 +41,7 @@ typedef struct AVTextWriter {
 void (*uninit)(AVTextWriterContext *wctx);
 void (*writer_w8)(AVTextWriterContext *wctx, int b);
 void (*writer_put_str)(AVTextWriterContext *wctx, const char *str);
-void (*writer_printf)(AVTextWriterContext *wctx, const char *fmt, ...);
+void (*writer_printf)(AVTextWriterContext *wctx, const char *fmt, va_list 
vl);
 } AVTextWriter;
 
 typedef struct AVTextWriterContext {
diff --git a/fftools/textformat/tf_compact.c b/fftools/textformat/tf_compact.c
index d4ac296a42..e52888239e 100644
--- a/fftools/textformat/tf_compact.c
+++ b/fftools/textformat/tf_compact.c
@@ -28,23 +28,7 @@
 #include "libavutil/bprint.h"
 #include "libavutil/error.h"
 #include "libavutil/opt.h"
-
-
-#define writer_w8(wctx_, b_) 
(wctx_)->writer->writer->writer_w8((wctx_)->writer, b_)
-#define writer_put_str(wctx_, str_) 
(wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_)
-#define writer_printf(wctx_, fmt_, ...) 
(wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__)
-
-
-#define DEFINE_FORMATTER_CLASS(name)   \
-static const char *name##_get_name(void *ctx)   \
-{   \
-return #name ;  \
-}   \
-static const AVClass name##_class = {   \
-.class_name = #name,\
-.item_name  = name##_get_name,  \
-.option = name##_options\
-}
+#include "tf_internal.h"
 
 
 /* Compact output */
@@ -157,9 +141,12 @@ static av_cold int compact_init(AVTextFormatContext *wctx)
 static void compact_print_section_header(AVTextFormatContext *wctx, const void 
*data)
 {
 CompactContext *compact = wctx->priv;
-const struct AVTextFormatSection *section = wctx->section[wctx->level];
-const struct AVTextFormatSection *parent_section = wctx->level ?
-wctx->section[wctx->level-1] : NULL;
+const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
+const AVTextFormatSection *parent_section = tf_get_parent_section(wctx, 
wctx->level);
+
+if (!section)
+return;
+
 compact->terminate_line[wctx->level] = 1;
 compact->has_nested_elems[wctx->level] = 0;
 
@@ -210,8 +197,11 @@ static void 
compact_print_section_header(AVTextFormatContext *wctx, const void *
 
 static void compact_print_section_footer(AVTextFormatContext *wctx)
 {
-const struct AVTextFormatSection *section = wctx->section[wctx->level];
 CompactContext *compact = wctx->priv;
+const AVTextFormatSection *section = tf_get_section(wctx, wctx->level);
+
+if (!section)
+return;
 
 if (!compact->nested_section[wctx->level] &&
 compact->terminate_line[wctx->level] &&
diff --git a/fftools/textformat/tf_default.c b/fftools/textformat/tf_default.c
index ad97173b0b..019bda9d44 100644
--- a/fftools/textformat/tf_default.c
+++ b/fftools/textformat/tf_default.c
@@ -27,21 +27,7 @@
 #include "avtextformat.h"
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
-
-#define writer_w8(wctx_, b_) 
(wctx_)->writer->writer->writer_w8((wctx_)->writer, b_)
-#define writer_put_str(wctx_, str_) 
(wctx_)->writer->writer->writer_put_str((wctx_)->writer, str_)
-#define writer_printf(wctx_, fmt_, ...) 
(wctx_)->writer->writer->writer_printf((wctx_)->writer, fmt_, __VA_ARGS__)
-
-#define DEFINE_FORMATTER_CLASS(name)   \
-static const char *name##_get_name(void *ctx)   \
-{   \
-return #name ;  \
-}   \
-static const AVClass name##_class = {   \
-.class_name = #name,\
-.item_name  = name##_get_name,  \
-.option = name##_options\
-}
+#include "tf_internal.h"
 
 /* Default output */
 
@@ -80,9 +66,11 @@ static void default_print_section_header(AVTextFormatCo

[FFmpeg-devel] [PATCH v2 02/10] fftools/textformat: Quality improvements

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 fftools/textformat/avtextformat.c | 111 +++---
 fftools/textformat/avtextformat.h |   6 +-
 fftools/textformat/tf_default.c   |   8 ++-
 fftools/textformat/tf_ini.c   |   2 +-
 fftools/textformat/tf_json.c  |   8 ++-
 fftools/textformat/tf_xml.c   |   3 -
 fftools/textformat/tw_avio.c  |   9 ++-
 7 files changed, 93 insertions(+), 54 deletions(-)

diff --git a/fftools/textformat/avtextformat.c 
b/fftools/textformat/avtextformat.c
index 811b14b999..4c8def8e65 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -93,9 +93,8 @@ static const AVClass textcontext_class = {
 
 static void bprint_bytes(AVBPrint *bp, const uint8_t *ubuf, size_t ubuf_size)
 {
-int i;
 av_bprintf(bp, "0X");
-for (i = 0; i < ubuf_size; i++)
+for (unsigned i = 0; i < ubuf_size; i++)
 av_bprintf(bp, "%02X", ubuf[i]);
 }
 
@@ -141,7 +140,10 @@ int avtext_context_open(AVTextFormatContext  **ptctx,
 AVTextFormatContext *tctx;
 int i, ret = 0;
 
-if (!(tctx = av_mallocz(sizeof(AVTextFormatContext {
+if (!ptctx || !formatter)
+return AVERROR(EINVAL);
+
+if (!((tctx = av_mallocz(sizeof(AVTextFormatContext) {
 ret = AVERROR(ENOMEM);
 goto fail;
 }
@@ -213,25 +215,26 @@ int avtext_context_open(AVTextFormatContext  **ptctx,
 av_log(NULL, AV_LOG_ERROR, " %s", n);
 av_log(NULL, AV_LOG_ERROR, "\n");
 }
-return ret;
+goto fail;
 }
 
 /* validate replace string */
 {
-const uint8_t *p = tctx->string_validation_replacement;
-const uint8_t *endp = p + strlen(p);
+const uint8_t *p = (uint8_t *)tctx->string_validation_replacement;
+const uint8_t *endp = p + strlen((const char *)p);
 while (*p) {
 const uint8_t *p0 = p;
 int32_t code;
 ret = av_utf8_decode(&code, &p, endp, 
tctx->string_validation_utf8_flags);
 if (ret < 0) {
 AVBPrint bp;
-av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
+av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
 bprint_bytes(&bp, p0, p - p0),
 av_log(tctx, AV_LOG_ERROR,
"Invalid UTF8 sequence %s found in string 
validation replace '%s'\n",
bp.str, tctx->string_validation_replacement);
-return ret;
+av_bprint_finalize(&bp, NULL);
+goto fail;
 }
 }
 }
@@ -259,6 +262,9 @@ static const char unit_bit_per_second_str[] = "bit/s";
 
 void avtext_print_section_header(AVTextFormatContext *tctx, const void *data, 
int section_id)
 {
+if (section_id < 0 || section_id >= tctx->nb_sections)
+return;
+
 tctx->level++;
 av_assert0(tctx->level < SECTION_MAX_NB_LEVELS);
 
@@ -272,6 +278,9 @@ void avtext_print_section_header(AVTextFormatContext *tctx, 
const void *data, in
 
 void avtext_print_section_footer(AVTextFormatContext *tctx)
 {
+if (tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
+return;
+
 int section_id = tctx->section[tctx->level]->id;
 int parent_section_id = tctx->level
 ? tctx->section[tctx->level - 1]->id
@@ -289,7 +298,12 @@ void avtext_print_section_footer(AVTextFormatContext *tctx)
 
 void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t 
val)
 {
-const struct AVTextFormatSection *section = tctx->section[tctx->level];
+const AVTextFormatSection *section;
+
+if (!key || tctx->level < 0 || tctx->level >= SECTION_MAX_NB_LEVELS)
+return;
+
+section = tctx->section[tctx->level];
 
 if (section->show_all_entries || av_dict_get(section->entries_to_show, 
key, NULL, 0)) {
 tctx->formatter->print_integer(tctx, key, val);
@@ -299,24 +313,25 @@ void avtext_print_integer(AVTextFormatContext *tctx, 
const char *key, int64_t va
 
 static inline int validate_string(AVTextFormatContext *tctx, char **dstp, 
const char *src)
 {
-const uint8_t *p, *endp;
+const uint8_t *p, *endp, *srcp = (const uint8_t *)src;
 AVBPrint dstbuf;
+AVBPrint bp;
 int invalid_chars_nb = 0, ret = 0;
 
+*dstp = NULL;
 av_bprint_init(&dstbuf, 0, AV_BPRINT_SIZE_UNLIMITED);
+av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
 
-endp = src + strlen(src);
-for (p = src; *p;) {
-uint32_t code;
+endp = srcp + strlen(src);
+for (p = srcp; *p;) {
+int32_t code;
 int invalid = 0;
 const uint8_t *p0 = p;
 
 if (av_utf8_decode(&code, &p, endp, 
tctx->string_validation_utf8_flags) < 0) {
-AVBPrint bp;
-av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
-bprint_bytes(&bp, p0, p-p0);
-av_log(tctx, AV_LOG_DEBUG,
-   "Invalid UTF-8 

[FFmpeg-devel] [PATCH v2 06/10] fftools/ffmpeg_filter: Move some declaration to new header file

2025-04-16 Thread softworkz
From: softworkz 

to allow filtergraph printing to access the information.

Signed-off-by: softworkz 
---
 fftools/ffmpeg_filter.c | 190 +---
 fftools/ffmpeg_filter.h | 234 
 2 files changed, 235 insertions(+), 189 deletions(-)
 create mode 100644 fftools/ffmpeg_filter.h

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d314aec206..eab9487f97 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -21,6 +21,7 @@
 #include 
 
 #include "ffmpeg.h"
+#include "ffmpeg_filter.h"
 
 #include "libavfilter/avfilter.h"
 #include "libavfilter/buffersink.h"
@@ -42,44 +43,6 @@
 // FIXME private header, used for mid_pred()
 #include "libavcodec/mathops.h"
 
-typedef struct FilterGraphPriv {
-FilterGraph  fg;
-
-// name used for logging
-char log_name[32];
-
-int  is_simple;
-// true when the filtergraph contains only meta filters
-// that do not modify the frame data
-int  is_meta;
-// source filters are present in the graph
-int  have_sources;
-int  disable_conversions;
-
-unsigned nb_outputs_done;
-
-const char  *graph_desc;
-
-int  nb_threads;
-
-// frame for temporarily holding output from the filtergraph
-AVFrame *frame;
-// frame for sending output to the encoder
-AVFrame *frame_enc;
-
-Scheduler   *sch;
-unsigned sch_idx;
-} FilterGraphPriv;
-
-static FilterGraphPriv *fgp_from_fg(FilterGraph *fg)
-{
-return (FilterGraphPriv*)fg;
-}
-
-static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg)
-{
-return (const FilterGraphPriv*)fg;
-}
 
 // data that is local to the filter thread and not visible outside of it
 typedef struct FilterGraphThread {
@@ -102,157 +65,6 @@ typedef struct FilterGraphThread {
 uint8_t *eof_out;
 } FilterGraphThread;
 
-typedef struct InputFilterPriv {
-InputFilter ifilter;
-
-InputFilterOptions  opts;
-
-int index;
-
-AVFilterContext*filter;
-
-// used to hold submitted input
-AVFrame*frame;
-
-/* for filters that are not yet bound to an input stream,
- * this stores the input linklabel, if any */
-uint8_t*linklabel;
-
-// filter data type
-enum AVMediaTypetype;
-// source data type: AVMEDIA_TYPE_SUBTITLE for sub2video,
-// same as type otherwise
-enum AVMediaTypetype_src;
-
-int eof;
-int bound;
-int drop_warned;
-uint64_tnb_dropped;
-
-// parameters configured for this input
-int format;
-
-int width, height;
-AVRational  sample_aspect_ratio;
-enum AVColorSpace   color_space;
-enum AVColorRange   color_range;
-
-int sample_rate;
-AVChannelLayout ch_layout;
-
-AVRational  time_base;
-
-AVFrameSideData   **side_data;
-int nb_side_data;
-
-AVFifo *frame_queue;
-
-AVBufferRef*hw_frames_ctx;
-
-int displaymatrix_present;
-int displaymatrix_applied;
-int32_t displaymatrix[9];
-
-int downmixinfo_present;
-AVDownmixInfo   downmixinfo;
-
-struct {
-AVFrame *frame;
-
-int64_t last_pts;
-int64_t end_pts;
-
-/// marks if sub2video_update should force an initialization
-unsigned int initialize;
-} sub2video;
-} InputFilterPriv;
-
-static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter)
-{
-return (InputFilterPriv*)ifilter;
-}
-
-typedef struct FPSConvContext {
-AVFrame  *last_frame;
-/* number of frames emitted by the video-encoding sync code */
-int64_t   frame_number;
-/* history of nb_frames_prev, i.e. the number of times the
- * previous frame was duplicated by vsync code in recent
- * do_video_out() calls */
-int64_t   frames_prev_hist[3];
-
-uint64_t  dup_warning;
-
-int   last_dropped;
-int   dropped_keyframe;
-
-enum VideoSyncMethod vsync_method;
-
-AVRationalframerate;
-AVRationalframerate_max;
-const AVRational *framerate_supported;
-int   framerate_clip;
-} FPSConvContext;
-
-typedef struct OutputFilterPriv {
-OutputFilterofilter;
-
-int index;
-
-void   *log_parent;
-charlog_name[32];
-
-char   *name;
-
-AVFilterContext*filter;
-
-/* desired output stream properties */
-int format;
-int width, height;
-int sample_rate;
-AVChannelLayout ch_layout;
-   

[FFmpeg-devel] [PATCH v2 07/10] avfilter/avfilter: Add avfilter_link_get_hw_frames_ctx()

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 doc/APIchanges |  3 +++
 libavfilter/avfilter.c |  9 +
 libavfilter/avfilter.h | 12 
 3 files changed, 24 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..32374f5453 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
 
 API changes, most recent first:
 
+2025-02-xx - xx - lavfi 10.10.100 - avfilter.h
+  Add avfilter_link_get_hw_frames_ctx().
+
 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
   Add AV_DICT_DEDUP.
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 64c1075c40..c76d43a215 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -989,6 +989,15 @@ enum AVMediaType avfilter_pad_get_type(const AVFilterPad 
*pads, int pad_idx)
 return pads[pad_idx].type;
 }
 
+AVBufferRef *avfilter_link_get_hw_frames_ctx(AVFilterLink *link)
+{
+FilterLink *plink = ff_filter_link(link);
+if (plink->hw_frames_ctx)
+return av_buffer_ref(plink->hw_frames_ctx);
+
+return NULL;
+}
+
 static int default_filter_frame(AVFilterLink *link, AVFrame *frame)
 {
 return ff_filter_frame(link->dst->outputs[0], frame);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index a89d3cf658..f85929dc5c 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -96,6 +96,18 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, 
int pad_idx);
  */
 enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx);
 
+/**
+ * Get the hardware frames context of a filter link.
+ *
+ * @param link an AVFilterLink
+ *
+ * @return a ref-counted copy of the link's hw_frames_ctx field if there is
+ * a hardware frames context associated with the link or NULL 
otherwise.
+ * The returned AVBufferRef needs to be released with av_buffer_unref()
+ * when it is no longer used.
+ */
+AVBufferRef* avfilter_link_get_hw_frames_ctx(AVFilterLink *link);
+
 /**
  * Lists of formats / etc. supported by an end of a link.
  *
-- 
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 05/10] fftools/textformat: Add function avtext_print_integer_flags()

2025-04-16 Thread softworkz
From: softworkz 

This function works analog to the avtext_print_string() which already
has a flags parameter.

Signed-off-by: softworkz 
---
 fftools/textformat/avtextformat.c | 21 +
 fftools/textformat/avtextformat.h |  2 ++
 2 files changed, 23 insertions(+)

diff --git a/fftools/textformat/avtextformat.c 
b/fftools/textformat/avtextformat.c
index 4c8def8e65..d96ced9b7d 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -311,6 +311,27 @@ void avtext_print_integer(AVTextFormatContext *tctx, const 
char *key, int64_t va
 }
 }
 
+void avtext_print_integer_flags(AVTextFormatContext *tctx, const char *key, 
int64_t val, int flags)
+{
+const AVTextFormatSection *section;
+
+if (!tctx || !key || tctx->level < 0 || tctx->level >= 
SECTION_MAX_NB_LEVELS)
+return;
+
+section = tctx->section[tctx->level];
+
+if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||
+(tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
+&& (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
+&& !(tctx->formatter->flags & 
AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS)))
+return;
+
+if (section->show_all_entries || av_dict_get(section->entries_to_show, 
key, NULL, 0)) {
+tctx->formatter->print_integer(tctx, key, val);
+tctx->nb_item[tctx->level]++;
+}
+}
+
 static inline int validate_string(AVTextFormatContext *tctx, char **dstp, 
const char *src)
 {
 const uint8_t *p, *endp, *srcp = (const uint8_t *)src;
diff --git a/fftools/textformat/avtextformat.h 
b/fftools/textformat/avtextformat.h
index aea691f351..16cd9b214f 100644
--- a/fftools/textformat/avtextformat.h
+++ b/fftools/textformat/avtextformat.h
@@ -139,6 +139,8 @@ void avtext_print_section_footer(AVTextFormatContext *tctx);
 
 void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t 
val);
 
+void avtext_print_integer_flags(AVTextFormatContext *tctx, const char *key, 
int64_t val, int flags);
+
 int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char 
*val, int flags);
 
 void avtext_print_unit_int(AVTextFormatContext *tctx, const char *key, int 
value, const char *unit);
-- 
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 04/10] fftools/tf_internal: Use ac_default_item_name

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 fftools/textformat/tf_internal.h | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/fftools/textformat/tf_internal.h b/fftools/textformat/tf_internal.h
index 7b326328cb..e145bc83bb 100644
--- a/fftools/textformat/tf_internal.h
+++ b/fftools/textformat/tf_internal.h
@@ -29,13 +29,9 @@
 #include "avtextformat.h"
 
 #define DEFINE_FORMATTER_CLASS(name)\
-static const char *name##_get_name(void *ctx)   \
-{   \
-return #name ;  \
-}   \
 static const AVClass name##_class = {   \
 .class_name = #name,\
-.item_name  = name##_get_name,  \
+.item_name  = av_default_item_name, \
 .option = name##_options\
 }
 
-- 
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 09/10] fftools/graphprint: Add execution graph printing

2025-04-16 Thread softworkz
From: softworkz 

The key benefits are:

- Different to other graph printing methods, this is outputting:
  - all graphs with runtime state
(including auto-inserted filters)
  - each graph with its inputs and outputs
  - all filters with their in- and output pads
  - all connections between all input- and output pads
  - for each connection:
- the runtime-negotiated format and media type
- the hw context
- if video hw context, both: hw pixfmt + sw pixfmt
- Output can either be printed to stdout or written to specified file
- Output is machine-readable
- Use the same output implementation as ffprobe, supporting multiple
  formats

Signed-off-by: softworkz 
---
 doc/ffmpeg.texi   |   10 +
 fftools/Makefile  |   17 +
 fftools/ffmpeg.c  |4 +
 fftools/ffmpeg.h  |3 +
 fftools/ffmpeg_filter.c   |5 +
 fftools/ffmpeg_opt.c  |   13 +
 fftools/graph/graphprint.c| 1102 +
 fftools/graph/graphprint.h|   30 +
 fftools/textformat/avtextformat.c |2 +
 fftools/textformat/avtextformat.h |   29 +
 fftools/textformat/tf_mermaid.c   |  655 +
 fftools/textformat/tf_mermaid.h   |   41 ++
 12 files changed, 1911 insertions(+)
 create mode 100644 fftools/graph/graphprint.c
 create mode 100644 fftools/graph/graphprint.h
 create mode 100644 fftools/textformat/tf_mermaid.c
 create mode 100644 fftools/textformat/tf_mermaid.h

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 17ba876ea3..35675b5309 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1394,6 +1394,16 @@ It is on by default, to explicitly disable it you need 
to specify @code{-nostats
 @item -stats_period @var{time} (@emph{global})
 Set period at which encoding progress/statistics are updated. Default is 0.5 
seconds.
 
+@item -print_graphs (@emph{global})
+Prints execution graph details to stderr in the format set via 
-print_graphs_format.
+
+@item -print_graphs_file @var{filename} (@emph{global})
+Writes execution graph details to the specified file in the format set via 
-print_graphs_format.
+
+@item -print_graphs_format @var{format} (@emph{global})
+Sets the output format (available formats are: default, compact, csv, flat, 
ini, json, xml, mermaid, mermaidhtml)
+The default format is json.
+
 @item -progress @var{url} (@emph{global})
 Send program-friendly progress information to @var{url}.
 
diff --git a/fftools/Makefile b/fftools/Makefile
index e9c9891c34..8d87ea8255 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -9,6 +9,8 @@ AVBASENAMES  = ffmpeg ffplay ffprobe
 ALLAVPROGS   = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF))
 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
 
+include $(SRC_PATH)/fftools/resources/Makefile
+
 OBJS-ffmpeg +=  \
 fftools/ffmpeg_dec.o\
 fftools/ffmpeg_demux.o  \
@@ -19,8 +21,21 @@ OBJS-ffmpeg +=  \
 fftools/ffmpeg_mux_init.o   \
 fftools/ffmpeg_opt.o\
 fftools/ffmpeg_sched.o  \
+fftools/graph/graphprint.o\
 fftools/sync_queue.o\
 fftools/thread_queue.o  \
+fftools/textformat/avtextformat.o \
+fftools/textformat/tf_compact.o   \
+fftools/textformat/tf_default.o   \
+fftools/textformat/tf_flat.o  \
+fftools/textformat/tf_ini.o   \
+fftools/textformat/tf_json.o  \
+fftools/textformat/tf_mermaid.o   \
+fftools/textformat/tf_xml.o   \
+fftools/textformat/tw_avio.o  \
+fftools/textformat/tw_buffer.o\
+fftools/textformat/tw_stdout.o\
+$(OBJS-resman)\
 
 OBJS-ffprobe +=   \
 fftools/textformat/avtextformat.o \
@@ -29,10 +44,12 @@ OBJS-ffprobe +=   \
 fftools/textformat/tf_flat.o  \
 fftools/textformat/tf_ini.o   \
 fftools/textformat/tf_json.o  \
+fftools/textformat/tf_mermaid.o   \
 fftools/textformat/tf_xml.o   \
 fftools/textformat/tw_avio.o  \
 fftools/textformat/tw_buffer.o\
 fftools/textformat/tw_stdout.o\
+$(OBJS-resman)\
 
 OBJS-ffplay += fftools/ffplay_renderer.o
 
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index dc321fb4a2..6766ec209c 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -81,6 +81,7 @@
 #include "ffmpeg.h"
 #include "ffmpeg_sched.h"
 #include "ffmpeg_utils.h"
+#include "graph/graphprint.h"
 
 const char program_name[] = "ffmpeg";
 const int program_birth_year = 2000;
@@ -308,6 +309,9 @@ const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL 
};
 
 static void ffmpeg_cleanup(int ret)
 {
+if (print_graphs || print_graphs_file)
+print_filtergraphs(filtergraphs, nb_filtergraphs, input_files, 
nb_input_files, output_files, nb_output_files);
+
 if (do_benchmark) {
 int64_t maxrss = getmaxrss() / 1024;
 av_log(NULL, AV_LOG_INFO, "bench: maxrss=%"PRId64"KiB\n", maxrss)

[FFmpeg-devel] [PATCH v2 08/10] fftools/resources: Add resource manager files

2025-04-16 Thread softworkz
From: softworkz 

Signed-off-by: softworkz 
---
 ffbuild/common.mak   |  28 ++-
 fftools/resources/.gitignore |   4 +
 fftools/resources/Makefile   |  27 +++
 fftools/resources/graph.css  | 353 +++
 fftools/resources/graph.html |  86 +
 fftools/resources/resman.c   | 213 +
 fftools/resources/resman.h   |  50 +
 7 files changed, 760 insertions(+), 1 deletion(-)
 create mode 100644 fftools/resources/.gitignore
 create mode 100644 fftools/resources/Makefile
 create mode 100644 fftools/resources/graph.css
 create mode 100644 fftools/resources/graph.html
 create mode 100644 fftools/resources/resman.c
 create mode 100644 fftools/resources/resman.h

diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index ca45a0f368..eb68796001 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -139,6 +139,32 @@ else
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst 
.,_,$(basename $(notdir $@)))
 endif
 
+# 1) Preprocess CSS to a minified version
+%.css.min: %.css
+   # Must start with a tab in the real Makefile
+   sed 's!/\\*.*\\*/!!g' $< \
+   | tr '\n' ' ' \
+   | tr -s ' ' \
+   | sed 's/^ //; s/ $$//' \
+   > $@
+
+# 2) Gzip the minified CSS
+%.css.min.gz: %.css.min
+   $(M)gzip -nc9 $< > $@
+
+# 3) Convert the gzipped CSS to a .c array
+%.css.c: %.css.min.gz $(BIN2CEXE)
+   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+
+# 4) Gzip the HTML file (no minification needed)
+%.html.gz: TAG = GZIP
+%.html.gz: %.html
+   $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) > $@
+
+# 5) Convert the gzipped HTML to a .c array
+%.html.c: %.html.gz $(BIN2CEXE)
+   $(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
+
 clean::
$(RM) $(BIN2CEXE) $(CLEANSUFFIXES:%=ffbuild/%)
 
@@ -214,7 +240,7 @@ $(TOOLOBJS): | tools
 
 OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) 
$(SHLIBOBJS) $(STLIBOBJS) $(TESTOBJS))
 
-CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx 
*.ptx.gz *.ptx.c *.ver *.version *$(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.gz *.css.c  
*$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
 LIBSUFFIXES   = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
 
 define RULES
diff --git a/fftools/resources/.gitignore b/fftools/resources/.gitignore
new file mode 100644
index 00..5f496535a6
--- /dev/null
+++ b/fftools/resources/.gitignore
@@ -0,0 +1,4 @@
+*.html.c
+*.css.c
+*.html.gz
+*.css.gz
diff --git a/fftools/resources/Makefile b/fftools/resources/Makefile
new file mode 100644
index 00..f3a0d0a970
--- /dev/null
+++ b/fftools/resources/Makefile
@@ -0,0 +1,27 @@
+clean::
+   $(RM) $(CLEANSUFFIXES:%=fftools/resources/%)
+
+
+HTML_RESOURCES := fftools/resources/graph.html \
+
+# .html => (gzip) .html.gz => (bin2c) .html.c => (cc) .o
+HTML_RESOURCES_GZ := $(HTML_RESOURCES:.html=.html.gz)
+HTML_RESOURCES_C := $(HTML_RESOURCES_GZ:.html.gz=.html.c)
+HTML_RESOURCES_OBJS := $(HTML_RESOURCES_C:.c=.o)
+
+CSS_RESOURCES := fftools/resources/graph.css   \
+
+# .css => (sh) .css.min  => (gzip) .css.min.gz => (bin2c) .css.c => (cc) .o
+CSS_RESOURCES_MIN := $(CSS_RESOURCES:.css=.css.min)
+CSS_RESOURCES_GZ := $(CSS_RESOURCES_MIN:.css.min=.css.min.gz)
+CSS_RESOURCES_C := $(CSS_RESOURCES_GZ:.css.min.gz=.css.c)
+CSS_RESOURCES_OBJS := $(CSS_RESOURCES_C:.c=.o)
+
+# Uncomment to prevent deletion
+#.PRECIOUS: %.css.c %.css.min %.css.gz  %.css.min.gz
+
+OBJS-resman +=  \
+fftools/resources/resman.o  \
+$(HTML_RESOURCES_OBJS)  \
+$(CSS_RESOURCES_OBJS)   \
+
diff --git a/fftools/resources/graph.css b/fftools/resources/graph.css
new file mode 100644
index 00..ab480673ab
--- /dev/null
+++ b/fftools/resources/graph.css
@@ -0,0 +1,353 @@
+/* Variables */
+.root {
+--ff-colvideo: #6eaa7b;
+--ff-colaudio: #477fb3;
+--ff-colsubtitle: #ad76ab;
+--ff-coltext: #666;
+}
+
+/* Common & Misc */
+.ff-inputfiles rect, .ff-outputfiles rect, .ff-inputstreams rect, 
.ff-outputstreams rect, .ff-decoders rect, .ff-encoders rect {
+stroke-width: 0;
+stroke: transparent;
+filter: none !important;
+fill: transparent !important;
+display: none !important;
+}
+
+.cluster span {
+color: var(--ff-coltext);
+}
+
+.cluster rect {
+stroke: #dfdfdf !important;
+transform: translateY(-2.3rem);
+filter: drop-shadow(1px 2px 2px rgba(185,185,185,0.2)) !important;
+rx: 8;
+ry: 8;
+}
+
+.cluster-label {
+font-size: 1.1rem;
+}
+
+.cluster-label .nodeLabel {
+display: block;
+font-weight: 500;
+color: var(--ff-coltext);
+}
+
+.cluster-label div {
+max-width: unset !important;
+padding: 3px;
+}
+
+.cluster-label foreignObject {
+transform: translateY(-0.7rem);
+}

[FFmpeg-devel] [PATCH v2 10/10] fftools/graphprint: Now, make it a Killer-Feature!

2025-04-16 Thread softworkz
From: softworkz 

remember this: -sg   <= show-graph

Signed-off-by: softworkz 
---
 doc/ffmpeg.texi  |   4 +
 fftools/Makefile |   1 +
 fftools/ffmpeg.c |   2 +-
 fftools/ffmpeg.h |   1 +
 fftools/ffmpeg_filter.c  |   2 +-
 fftools/ffmpeg_opt.c |   4 +
 fftools/graph/filelauncher.c | 204 +++
 fftools/graph/graphprint.c   |  50 -
 fftools/graph/graphprint.h   |  32 ++
 9 files changed, 295 insertions(+), 5 deletions(-)
 create mode 100644 fftools/graph/filelauncher.c

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 35675b5309..6e9e7aed0e 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1404,6 +1404,10 @@ Writes execution graph details to the specified file in 
the format set via -prin
 Sets the output format (available formats are: default, compact, csv, flat, 
ini, json, xml, mermaid, mermaidhtml)
 The default format is json.
 
+@item -sg (@emph{global})
+Writes the execution graph to a temporary html file (mermaidhtml format) and 
+tries to launch it in the default browser.
+
 @item -progress @var{url} (@emph{global})
 Send program-friendly progress information to @var{url}.
 
diff --git a/fftools/Makefile b/fftools/Makefile
index 8d87ea8255..1d1d8a818d 100644
--- a/fftools/Makefile
+++ b/fftools/Makefile
@@ -22,6 +22,7 @@ OBJS-ffmpeg +=  \
 fftools/ffmpeg_opt.o\
 fftools/ffmpeg_sched.o  \
 fftools/graph/graphprint.o\
+fftools/graph/filelauncher.o  \
 fftools/sync_queue.o\
 fftools/thread_queue.o  \
 fftools/textformat/avtextformat.o \
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6766ec209c..9875a1f7fd 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -309,7 +309,7 @@ const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL 
};
 
 static void ffmpeg_cleanup(int ret)
 {
-if (print_graphs || print_graphs_file)
+if (print_graphs || print_graphs_file || show_graph)
 print_filtergraphs(filtergraphs, nb_filtergraphs, input_files, 
nb_input_files, output_files, nb_output_files);
 
 if (do_benchmark) {
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 7fbf0ad532..49fea0307d 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -721,6 +721,7 @@ extern int print_graphs;
 extern char *print_graphs_file;
 extern char *print_graphs_format;
 extern int auto_conversion_filters;
+extern int show_graph;
 
 extern const AVIOInterruptCB int_cb;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index b774606562..e82e333b7f 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2985,7 +2985,7 @@ read_frames:
 
 finish:
 
-if (print_graphs || print_graphs_file)
+if (print_graphs || print_graphs_file || show_graph)
 print_filtergraph(fg, fgt.graph);
 
 // EOF is normal termination
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 3d1efe32f9..24713d640f 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -79,6 +79,7 @@ int vstats_version = 2;
 int print_graphs = 0;
 char *print_graphs_file = NULL;
 char *print_graphs_format = NULL;
+int show_graph = 0;
 int auto_conversion_filters = 1;
 int64_t stats_period = 50;
 
@@ -1748,6 +1749,9 @@ const OptionDef options[] = {
 { "print_graphs_format", OPT_TYPE_STRING, 0,
 { &print_graphs_format },
   "set the output printing format (available formats are: default, 
compact, csv, flat, ini, json, xml, mermaid, mermaidhtml)", "format" },
+{ "sg",   OPT_TYPE_BOOL, 0,
+{ &show_graph },
+"create execution graph as temporary html file and try to launch it in 
the default browser" },
 { "auto_conversion_filters", OPT_TYPE_BOOL, OPT_EXPERT,
 { &auto_conversion_filters },
 "enable automatic conversion filters globally" },
diff --git a/fftools/graph/filelauncher.c b/fftools/graph/filelauncher.c
new file mode 100644
index 00..ae9d88c2e4
--- /dev/null
+++ b/fftools/graph/filelauncher.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 2025 - softworkz
+ *
+ * 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 
+#include 
+#include 
+
+#if defined(_WIN32)
+#  include 
+#else
+#  include 
+#  include 
+#endif
+#incl

Re: [FFmpeg-devel] [PATCH v2 00/10] Execution Graph Printing

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpegagent 
> Sent: Mittwoch, 16. April 2025 12:12
> To: ffmpeg-devel@ffmpeg.org
> Cc: softworkz 
> Subject: [PATCH v2 00/10] Execution Graph Printing
> 
> Shortest cover letter for my longest-running FFmpeg patchset:
> 
>  * Apply
>  * Build
>  * Add the "-sg" switch to any FFmpeg command line
>  * Press 'q' when you don't want to wait
> 
> SG = Show Graph
> 
> Documentation and examples can be found here:
> 
> https://github.com/softworkz/ffmpeg_output_apis/wiki
> 
> 
> ===

Hello,

has anybody tried this on a Mac? 

Or would someone be able to try? It's only about whether the
browser-launch is working when specifying -sg, as I don't
have a Mac available.

Thanks
sw




___
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] fate: add various FFv1 tests for 1024 slices

2025-04-16 Thread Andreas Rheinhardt
Lynne:
> This lets us test features that were broken earlier, as well as
> test the hardware decoder by using the HWACCEL=vulkan option.

Can't you just adjust some of vsynth FFV1 tests to use this many slices?
(Can one even use 1024 slices for such a low resolution?)

> ---
>  tests/Makefile  |  1 +
>  tests/fate/ffv1.mak | 53 +
>  tests/ref/fate/ffv1-s1024-bgra  |  4 +++
>  tests/ref/fate/ffv1-s1024-bgra-r|  4 +++
>  tests/ref/fate/ffv1-s1024-gbrp16|  4 +++
>  tests/ref/fate/ffv1-s1024-gray8 |  4 +++
>  tests/ref/fate/ffv1-s1024-gray8-r   |  4 +++
>  tests/ref/fate/ffv1-s1024-yuv444p   |  4 +++
>  tests/ref/fate/ffv1-s1024-yuv444p-r |  4 +++
>  9 files changed, 82 insertions(+)
>  create mode 100644 tests/fate/ffv1.mak
>  create mode 100644 tests/ref/fate/ffv1-s1024-bgra
>  create mode 100644 tests/ref/fate/ffv1-s1024-bgra-r
>  create mode 100644 tests/ref/fate/ffv1-s1024-gbrp16
>  create mode 100644 tests/ref/fate/ffv1-s1024-gray8
>  create mode 100644 tests/ref/fate/ffv1-s1024-gray8-r
>  create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p
>  create mode 100644 tests/ref/fate/ffv1-s1024-yuv444p-r
> 
> diff --git a/tests/Makefile b/tests/Makefile
> index f9f5fc07f3..b2386febd7 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -180,6 +180,7 @@ include $(SRC_PATH)/tests/fate/enc_external.mak
>  # Must be included after lavf-video.mak
>  include $(SRC_PATH)/tests/fate/ffmpeg.mak
>  include $(SRC_PATH)/tests/fate/ffprobe.mak
> +include $(SRC_PATH)/tests/fate/ffv1.mak
>  include $(SRC_PATH)/tests/fate/fifo-muxer.mak
>  include $(SRC_PATH)/tests/fate/filter-audio.mak
>  # Must be included after vcodec.mak
> diff --git a/tests/fate/ffv1.mak b/tests/fate/ffv1.mak
> new file mode 100644
> index 00..16660b5ac2
> --- /dev/null
> +++ b/tests/fate/ffv1.mak
> @@ -0,0 +1,53 @@
> +FATE_FFV1 += fate-ffv1-s1024-gray8
> +fate-ffv1-s1024-gray8: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-gray8: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \

Seems like you are treating the input file as gray8 (as opposed to
converting it to gray8). Is this intended? Can't this cause problems
because the size of the input file is not necessarily a multiple of the
size expected for a 352x288 gray8 frame?

> +  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-gray8-r
> +fate-ffv1-s1024-gray8-r: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-gray8-r: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt gray8" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-yuv444p
> +fate-ffv1-s1024-yuv444p: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-yuv444p: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-yuv444p-r
> +fate-ffv1-s1024-yuv444p-r: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-yuv444p-r: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt yuv444p" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-bgra
> +fate-ffv1-s1024-bgra: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-bgra: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-bgra-r
> +fate-ffv1-s1024-bgra-r: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-bgra-r: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt bgra" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder rice" \
> +  framecrc "" ""
> +
> +FATE_FFV1 += fate-ffv1-s1024-gbrp16
> +fate-ffv1-s1024-gbrp16: tests/data/vsynth1.yuv
> +fate-ffv1-s1024-gbrp16: CMD = enc_dec \
> +  "rawvideo -s 352x288 -pix_fmt gbrp16" tests/data/vsynth1.yuv \
> +  nut "-c ffv1 -g 1 -slices 1024 -coder ac" \
> +  framecrc "" ""

Won't this test cause issues on BE?

> +
> +FATE_FFV1-$(call ENCDEC, FFV1, NUT) += $(FATE_FFV1)
> +FATE_FFV1_ALL = $(FATE_FFV1-yes)
> +FATE_SAMPLES_FFMPEG += $(FATE_FFV1_ALL)
> +fate-ffv1: $(FATE_FFV1_ALL)
> diff --git a/tests/ref/fate/ffv1-s1024-bgra b/tests/ref/fate/ffv1-s1024-bgra
> new file mode 100644
> index 00..9e8ecb0d17
> --- /dev/null
> +++ b/tests/ref/fate/ffv1-s1024-bgra
> @@ -0,0 +1,4 @@
> +b5374eb750c4eb58be89e56adba70294 *tests/data/fate/ffv1-s1024-bgra.nut
> +5952517 tests/data/fate/ffv1-s1024-bgra.nut
> +5a62bfcd55a764b27412ff4aa710d43a 
> *tests/data/fate/ffv1-s1024-bgra.out.framecrc
> +stddev:28579.81 PSNR:  7.21 MAXDIFF:60652 bytes:  7603200/ 1134

Why does this show differences given that FFV1 is a lossless encoder? Is
it due to the input file size not being a multiple of the expected size
for a 352x288 frame of type bgra?

> diff --git a/tests/ref/fate/ffv1-s1024-bgra-r 
> b/tests/ref/fate/ffv

Re: [FFmpeg-devel] [PATCH] fate/vvc: Add vvc-wpp-single-slice-pic

2025-04-16 Thread Nuo Mi
Thank you, Frank.

Hi samples-request,
could you help

On Wed, Apr 9, 2025 at 12:29 AM Frank Plowman  wrote:

> On 24/03/2025 18:10, Frank Plowman wrote:
> > A sample with a particular partitioning structure that could not be read
> > correctly before 26c5d8cf5d6dcd520e781754d986e9907d74270e
> >
> > Signed-off-by: Frank Plowman 
> > ---
> >  tests/fate/vvc.mak  | 10 ++
> >  tests/ref/fate/vvc-wpp-single-slice-pic |  6 ++
> >  2 files changed, 12 insertions(+), 4 deletions(-)
> >  create mode 100644 tests/ref/fate/vvc-wpp-single-slice-pic
> >
> > diff --git a/tests/fate/vvc.mak b/tests/fate/vvc.mak
> > index 532bf44e19..c882010713 100644
> > --- a/tests/fate/vvc.mak
> > +++ b/tests/fate/vvc.mak
> > @@ -44,12 +44,14 @@ $(VVC_TESTS_444_10BIT): SCALE_OPTS := -pix_fmt
> yuv444p10le -vf scale
> >  fate-vvc-conformance-%: CMD = framecrc -c:v vvc -i
> $(TARGET_SAMPLES)/vvc-conformance/$(subst fate-vvc-conformance-,,$(@)).bit
> $(SCALE_OPTS)
> >  fate-vvc-output-ref: CMD = framecrc -c:v vvc -i
> $(TARGET_SAMPLES)/vvc/Hierarchical.bit $(SCALE_OPTS)
> >  fate-vvc-frames-with-ltr: CMD = framecrc -c:v vvc -i
> $(TARGET_SAMPLES)/vvc/vvc_frames_with_ltr.vvc -pix_fmt yuv420p10le -vf scale
> > +fate-vvc-wpp-single-slice-pic: CMD = framecrc -c:v vvc -i
> $(TARGET_SAMPLES)/vvc/wpp-single-slice-pic.vvc -pix_fmt yuv420p10le -vf
> scale
> >
> >  FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER) += $(VVC_TESTS_8BIT)
> fate-vvc-output-ref
> > -FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER SCALE_FILTER) +=
>   \
> > -$(VVC_TESTS_10BIT)
>  \
> > -
> $(VVC_TESTS_444_10BIT)   \
> > -
> fate-vvc-frames-with-ltr \
> > +FATE_VVC-$(call FRAMECRC, VVC, VVC, VVC_PARSER SCALE_FILTER) +=
>\
> > +$(VVC_TESTS_10BIT)
>   \
> > +
> $(VVC_TESTS_444_10BIT)\
> > +
> fate-vvc-frames-with-ltr  \
> > +
> fate-vvc-wpp-single-slice-pic \
> >
> >  FATE_SAMPLES_FFMPEG += $(FATE_VVC-yes)
> >
> > diff --git a/tests/ref/fate/vvc-wpp-single-slice-pic
> b/tests/ref/fate/vvc-wpp-single-slice-pic
> > new file mode 100644
> > index 00..d3629a8d80
> > --- /dev/null
> > +++ b/tests/ref/fate/vvc-wpp-single-slice-pic
> > @@ -0,0 +1,6 @@
> > +#tb 0: 1/25
> > +#media_type 0: video
> > +#codec_id 0: rawvideo
> > +#dimensions 0: 256x256
> > +#sar 0: 0/1
> > +0,  0,  0,1,   196608, 0x49771161
>
> Ping
>
> ___
> 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] avutil/map: replace passing Compare functions by flags

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 22:12
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: [FFmpeg-devel] [PATCH] avutil/map: replace passing Compare
> functions by flags
> 
> This makes the API much more robust because if you receive a map
> from some other module you no longer need to know which
> compare function is correct for it
> Instead you just specify what you need, like
> AV_MAP_CMP_CASE_SENSITIVE or AV_MAP_CMP_CASE_INSENSITIVE or 0 if you
> dont care
> and the code will either do what you asked for or cleanly fail if its
> unable to
> previously it would just give you a wrong result sometimes
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavutil/map.c   | 80 +++---
> -
>  libavutil/map.h   | 53 +---
>  libavutil/tests/map.c | 45 
>  3 files changed, 137 insertions(+), 41 deletions(-)
> 
> diff --git a/libavutil/map.c b/libavutil/map.c
> index 00dd5a1bd39..950473c2c45 100644
> --- a/libavutil/map.c
> +++ b/libavutil/map.c
> @@ -35,7 +35,8 @@ typedef struct{
>  } AVMapInternalEntry;
> 
>  struct AVMap{
> -AVMapCompareFunc cmp_keyvalue;
> +#define CMP_MASK 31
> +AVMapCompareFunc cmp[27];
>  AVMapCopyFunc copy;
>  AVMapFreeFunc freef;
>  int count;
> @@ -98,24 +99,71 @@ int av_map_supercmp_keyvalue(const char *a, const
> char *b)
>  return v;
>  }
> 
> -AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, AVMapCopyFunc copy,
> AVMapFreeFunc freef)
> +int av_map_add_cmp_func(AVMap *m, AVMapCompareFunc cmp, int
> cmp_flags)
> +{
> +static const uint8_t sensitivity[27][3] = {
> +{0,0, 0},{1,0, 0},{2,0, 0}, {0,3, 0},{1,3, 0},{2,3, 0}, {0,6,
> 0},{1,6, 0},{2,6, 0},
> +{0,0, 9},{1,0, 9},{2,0, 9}, {0,3, 9},{1,3, 9},{2,3, 9}, {0,6,
> 9},{1,6, 9},{2,6, 9},
> +{0,0,18},{1,0,18},{2,0,18}, {0,3,18},{1,3,18},{2,3,18},
> {0,6,18},{1,6,18},{2,6,18},};
> +int case_sensitive   =  sensitivity[cmp_flags][0];
> +int keyvalue_sensitive   =  sensitivity[cmp_flags][1];
> +int truncated_sensitive  =  sensitivity[cmp_flags][2];
> +
> +if (!keyvalue_sensitive || !truncated_sensitive || cmp_flags >=
> 27U)
> +return AVERROR(EINVAL);
> +
> +av_assert1(case_sensitive + keyvalue_sensitive +
> truncated_sensitive == cmp_flags);
> +
> +if ( case_sensitive == AV_MAP_CMP_CASE_SENSITIVE && m-
> >cmp[keyvalue_sensitive + AV_MAP_CMP_CASE_INSENSITIVE])
> +return AVERROR(EINVAL);
> +if ( keyvalue_sensitive == AV_MAP_CMP_KEYVALUE   && m-
> >cmp[AV_MAP_CMP_KEY])
> +return AVERROR(EINVAL);
> +if (truncated_sensitive == AV_MAP_CMP_NON_TRUNCATED  && m-
> >cmp[keyvalue_sensitive + AV_MAP_CMP_TRUNCATED])
> +return AVERROR(EINVAL);
> +
> +//max functions is KV NT CS -> KV NT CI -> KV T CI (CI/T is about
> value only) -> K NT CS -> K NT CI -> K T CI
> +//missing is KV T CS and K T CS, with them we can have KV NT CS -
> > KV T CS -> K NT CS -> K T CS
> +
> +for (int i=0; i<8; i++) {
> +int flags = 0;
> +if (i&1) flags += case_sensitive;
> +if (i&2) flags += keyvalue_sensitive;
> +if (i&4) flags += truncated_sensitive;
> +
> +if (!m->cmp[flags])
> +m->cmp[flags] = cmp;
> +}
> +return 0;
> +}
> +
> +int av_map_is_cmp_flags_supported(AVMap *m, int cmp_flags)
> +{
> +if (cmp_flags >= 27U)
> +return AVERROR(EINVAL);
> +return !!m->cmp[cmp_flags];
> +}
> +
> +AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, int cmp_flags,
> AVMapCopyFunc copy, AVMapFreeFunc freef)
>  {
>  AVMap *s = av_mallocz(sizeof(*s));
>  if (!s)
>  return NULL;
> 
> -s->cmp_keyvalue  = cmp_keyvalue;
>  s->copy  = copy;
>  s->freef = freef;
> 
> +av_map_add_cmp_func(s, cmp_keyvalue, cmp_flags);
> +
>  return s;
>  }
> 
> -const AVMapEntry *av_map_get_multiple(const AVMap *s, const
> AVMapEntry *prev, const char *keyvalue, int (*cmp)(const void
> *keyvalue, const void *b))
> +const AVMapEntry *av_map_get_multiple(const AVMap *s, const
> AVMapEntry *prev, const char *keyvalue, int flags)
>  {
> +AVMapCompareFunc cmp = s->cmp[flags & CMP_MASK];
> +
>  if (prev) {
>  void *next_node[2] = { NULL, NULL };
> -void *prev_keyvalue = av_tree_find2(s->tree_root, prev->key,
> s->cmp_keyvalue, next_node, 2);
> +void *prev_keyvalue = av_tree_find2(s->tree_root, prev->key,
> s->cmp[0], next_node, 2);
>  av_assert2(prev_keyvalue);
>  if (!next_node[1] || cmp(next_node[1], keyvalue))
>  return NULL;
> @@ -134,8 +182,10 @@ const AVMapEntry *av_map_get_multiple(const AVMap
> *s, const AVMapEntry *prev, co
>  return &keyvalue2internal(keyvalue)->map_entry;
>  }
> 
> -const AVMapEntry *av_map_get(const AVMap *s, const char *keyvalue,
> int (*cmp)(const void *keyvalue, con

[FFmpeg-devel] [PATCH] avutil/x86: Improve ELF PIC support for external function calls

2025-04-16 Thread James Almer
From: Henrik Gramner 

PLT/GOT indirections are required in some cases. Most commonly when
calling functions from other shared libraries, but also in some
scenarios when calling functions with default symbol visibility
even within the same component on certain elf64 platforms.

On elf64 we can simply use PLT relocations for all calls to external
functions. Since the linker is able to eliminate unnecessary PLT
indirections with the final output binary being identical to non-PLT
relocations there isn't really any downside to doing so. This mimics
what regular compilers normally do for calls to external functions.

On elf32 with PIC we can use a function pointer from the GOT when
calling external functions, similar to what regular compilers do when
using -fno-plt. Since this both introduces overhead and clobbers one
register, which could potentially have been used for custom calling
conventions when calling other asm functions within the same library,
it's only performed for functions declared using 'cextern_naked'.

Signed-off-by: James Almer 
---
 libavutil/x86/x86inc.asm | 25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index e61d924bc1..40d2e16d84 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -242,7 +242,7 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
 %elif PIC
 call $+5 ; special-cased to not affect the RSB on most CPU:s
 pop %1
-add %1, (%2)-$+1
+add %1, -$+1+%2
 %else
 mov %1, %2
 %endif
@@ -874,16 +874,16 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg, 
jge, jng, jnge, ja, jae,
 
 %macro cextern 1
 %xdefine %1 mangle(private_prefix %+ _ %+ %1)
-CAT_XDEFINE cglobaled_, %1, 1
+CAT_XDEFINE cglobaled_, %1, 2
 extern %1
 %endmacro
 
-; like cextern, but without the prefix
+; Like cextern, but without the prefix. This should be used for symbols from 
external libraries.
 %macro cextern_naked 1
 %ifdef PREFIX
 %xdefine %1 mangle(%1)
 %endif
-CAT_XDEFINE cglobaled_, %1, 1
+CAT_XDEFINE cglobaled_, %1, 3
 extern %1
 %endmacro
 
@@ -1278,12 +1278,27 @@ INIT_XMM
 %endmacro
 %macro call_internal 2
 %xdefine %%i %2
+%define %%j %%i
 %ifndef cglobaled_%2
 %ifdef cglobaled_%1
 %xdefine %%i %1
 %endif
+%elif FORMAT_ELF
+%if ARCH_X86_64
+%if cglobaled_%2 >= 2
+; Always emit PLT relocations when calling external functions,
+; the linker will eliminate unnecessary PLT indirections 
anyway.
+%define %%j %%i wrt ..plt
+%endif
+%elif PIC && cglobaled_%2 == 3
+; Go through the GOT for functions declared using cextern_naked 
with
+; PIC, as such functions presumably exists in external libraries.
+extern _GLOBAL_OFFSET_TABLE_
+LEA eax, $$+_GLOBAL_OFFSET_TABLE_ wrt ..gotpc
+%define %%j [eax+%%i wrt ..got]
+%endif
 %endif
-call %%i
+call %%j
 LOAD_MM_PERMUTATION %%i
 %endmacro
 
-- 
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".


Re: [FFmpeg-devel] [PATCH 2/3] doc/dict2: Add doc and api change for AVDictionary2

2025-04-16 Thread Michael Niedermayer
Hi softworkz

I think we should use AI to support us and reduce the workload
on people.
I think this here cost you money and iam not sure this isnt
adding workload and maybe even increased disagreements between
people

can you get AI to do something nooone else is working on ?
or to support someone on what she is working on. This here
is a bit more a opposition submission.
Id love it if AI would submit bugfixes to my code for example
or if it would submit patches improving my code

Or maybeit could fix a random ticket chance of collision
with a human is pretty low

thx

On Sat, Apr 12, 2025 at 03:11:57PM +, softworkz wrote:
[...]
> +AVDictionary2 is a hash table-based key-value dictionary implementation that 
> provides significant performance improvements over the original AVDictionary 
> implementation.
> +
> +## Overview
> +
> +The implementation uses:
> +
> +- Hash table with chaining for collision resolution
> +- Automatic table resizing when load factor exceeds 0.75
> +- Optimized key/value storage management
> +- Efficient iteration through entries
> +
> +## Performance
> +
> +### Time Complexity
> +AVDictionary2 offers substantial time complexity improvements:
> +
> +| Operation | AVDictionary (Linked List) | AVDictionary2 (Hash Table) |
> +|---|||
> +| Insert| O(n)*  | O(1) avg, O(n) worst   |
> +| Lookup| O(n)   | O(1) avg, O(n) worst   |

One of the issues with AVDictionary is that its very slow with crafted
data, Classic hash tables dont improve that.
Which is one reason why i did go for the tree and not a hash table
also AV_DICT_IGNORE_SUFFIX, is not hash table friendly and not supported
by this


> +| Iteration | O(n)   | O(n)   |
> +
> +*Where n is current dictionary size due to duplicate checking
> +
> +### Memory Characteristics
> +
> +**Original AVDictionary (dict.c)**
> +- 2 allocations per entry (key + value string duplicates)
> +- Dynamic array with O(log n) reallocations

> +- Total: ~2n + log₂(n) allocations for n entries

I dont think this is correct, not that this matters

also another key question, who would maintain AI generated code ?
and for the specific case of string based has tables, i wager a bet
that theres some maintained code somewhere on github.

thx

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

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope


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] avutil/map: replace passing Compare functions by flags

2025-04-16 Thread Michael Niedermayer
This makes the API much more robust because if you receive a map
from some other module you no longer need to know which
compare function is correct for it
Instead you just specify what you need, like
AV_MAP_CMP_CASE_SENSITIVE or AV_MAP_CMP_CASE_INSENSITIVE or 0 if you dont care
and the code will either do what you asked for or cleanly fail if its unable to
previously it would just give you a wrong result sometimes

Signed-off-by: Michael Niedermayer 
---
 libavutil/map.c   | 80 +++
 libavutil/map.h   | 53 +---
 libavutil/tests/map.c | 45 
 3 files changed, 137 insertions(+), 41 deletions(-)

diff --git a/libavutil/map.c b/libavutil/map.c
index 00dd5a1bd39..950473c2c45 100644
--- a/libavutil/map.c
+++ b/libavutil/map.c
@@ -35,7 +35,8 @@ typedef struct{
 } AVMapInternalEntry;
 
 struct AVMap{
-AVMapCompareFunc cmp_keyvalue;
+#define CMP_MASK 31
+AVMapCompareFunc cmp[27];
 AVMapCopyFunc copy;
 AVMapFreeFunc freef;
 int count;
@@ -98,24 +99,71 @@ int av_map_supercmp_keyvalue(const char *a, const char *b)
 return v;
 }
 
-AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, AVMapCopyFunc copy, 
AVMapFreeFunc freef)
+int av_map_add_cmp_func(AVMap *m, AVMapCompareFunc cmp, int cmp_flags)
+{
+static const uint8_t sensitivity[27][3] = {
+{0,0, 0},{1,0, 0},{2,0, 0}, {0,3, 0},{1,3, 0},{2,3, 0}, {0,6, 0},{1,6, 
0},{2,6, 0},
+{0,0, 9},{1,0, 9},{2,0, 9}, {0,3, 9},{1,3, 9},{2,3, 9}, {0,6, 9},{1,6, 
9},{2,6, 9},
+{0,0,18},{1,0,18},{2,0,18}, {0,3,18},{1,3,18},{2,3,18}, 
{0,6,18},{1,6,18},{2,6,18},};
+int case_sensitive   =  sensitivity[cmp_flags][0];
+int keyvalue_sensitive   =  sensitivity[cmp_flags][1];
+int truncated_sensitive  =  sensitivity[cmp_flags][2];
+
+if (!keyvalue_sensitive || !truncated_sensitive || cmp_flags >= 27U)
+return AVERROR(EINVAL);
+
+av_assert1(case_sensitive + keyvalue_sensitive + truncated_sensitive == 
cmp_flags);
+
+if ( case_sensitive == AV_MAP_CMP_CASE_SENSITIVE && 
m->cmp[keyvalue_sensitive + AV_MAP_CMP_CASE_INSENSITIVE])
+return AVERROR(EINVAL);
+if ( keyvalue_sensitive == AV_MAP_CMP_KEYVALUE   && 
m->cmp[AV_MAP_CMP_KEY])
+return AVERROR(EINVAL);
+if (truncated_sensitive == AV_MAP_CMP_NON_TRUNCATED  && 
m->cmp[keyvalue_sensitive + AV_MAP_CMP_TRUNCATED])
+return AVERROR(EINVAL);
+
+//max functions is KV NT CS -> KV NT CI -> KV T CI (CI/T is about value 
only) -> K NT CS -> K NT CI -> K T CI
+//missing is KV T CS and K T CS, with them we can have KV NT CS -> KV T CS 
-> K NT CS -> K T CS
+
+for (int i=0; i<8; i++) {
+int flags = 0;
+if (i&1) flags += case_sensitive;
+if (i&2) flags += keyvalue_sensitive;
+if (i&4) flags += truncated_sensitive;
+
+if (!m->cmp[flags])
+m->cmp[flags] = cmp;
+}
+return 0;
+}
+
+int av_map_is_cmp_flags_supported(AVMap *m, int cmp_flags)
+{
+if (cmp_flags >= 27U)
+return AVERROR(EINVAL);
+return !!m->cmp[cmp_flags];
+}
+
+AVMap *av_map_new(AVMapCompareFunc cmp_keyvalue, int cmp_flags, AVMapCopyFunc 
copy, AVMapFreeFunc freef)
 {
 AVMap *s = av_mallocz(sizeof(*s));
 if (!s)
 return NULL;
 
-s->cmp_keyvalue  = cmp_keyvalue;
 s->copy  = copy;
 s->freef = freef;
 
+av_map_add_cmp_func(s, cmp_keyvalue, cmp_flags);
+
 return s;
 }
 
-const AVMapEntry *av_map_get_multiple(const AVMap *s, const AVMapEntry *prev, 
const char *keyvalue, int (*cmp)(const void *keyvalue, const void *b))
+const AVMapEntry *av_map_get_multiple(const AVMap *s, const AVMapEntry *prev, 
const char *keyvalue, int flags)
 {
+AVMapCompareFunc cmp = s->cmp[flags & CMP_MASK];
+
 if (prev) {
 void *next_node[2] = { NULL, NULL };
-void *prev_keyvalue = av_tree_find2(s->tree_root, prev->key, 
s->cmp_keyvalue, next_node, 2);
+void *prev_keyvalue = av_tree_find2(s->tree_root, prev->key, 
s->cmp[0], next_node, 2);
 av_assert2(prev_keyvalue);
 if (!next_node[1] || cmp(next_node[1], keyvalue))
 return NULL;
@@ -134,8 +182,10 @@ const AVMapEntry *av_map_get_multiple(const AVMap *s, 
const AVMapEntry *prev, co
 return &keyvalue2internal(keyvalue)->map_entry;
 }
 
-const AVMapEntry *av_map_get(const AVMap *s, const char *keyvalue, int 
(*cmp)(const void *keyvalue, const void *b))
+const AVMapEntry *av_map_get(const AVMap *s, const char *keyvalue, int flags)
 {
+AVMapCompareFunc cmp = s->cmp[flags & CMP_MASK];
+
 keyvalue = av_tree_find2(s->tree_root, keyvalue, cmp, NULL, 0);
 
 if (!keyvalue)
@@ -192,15 +242,15 @@ int av_map_add(AVMap *s, const char *key, int keylen, 
const char *value, int val
 memcpy(entry->key  , key  , keylen);
 memcpy(entry->value, value, valuelen);
 
-void *elem = av_tree_insert(&s->tree_root, entry->key, s->cmp_keyvalue, 
&next);
+void *elem = av

Re: [FFmpeg-devel] [PATCH] libpostproc/postprocess: Fix deprecating PP_CPU_CAPS_3DNO

2025-04-16 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Patch attached.
> 
> - Andreas
> 
Ignore this, it has already been fixed in master.

- 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 v3 2/2] ffprobe: show seekability details in format section

2025-04-16 Thread Gyan Doshi
---
 doc/ffprobe.xsd  |  2 ++
 fftools/ffprobe.c| 15 ++-
 tests/ref/fate/cavs-demux|  2 +-
 tests/ref/fate/ffprobe_compact   |  2 +-
 tests/ref/fate/ffprobe_csv   |  2 +-
 tests/ref/fate/ffprobe_default   |  2 ++
 tests/ref/fate/ffprobe_flat  |  2 ++
 tests/ref/fate/ffprobe_ini   |  2 ++
 tests/ref/fate/ffprobe_json  |  2 ++
 tests/ref/fate/ffprobe_xml   |  2 +-
 tests/ref/fate/ffprobe_xsd   |  2 +-
 tests/ref/fate/flv-demux |  2 +-
 tests/ref/fate/gapless-mp3-side-data |  2 +-
 tests/ref/fate/oggopus-demux |  2 +-
 tests/ref/fate/ts-demux  |  2 +-
 tests/ref/fate/ts-opus-demux |  2 +-
 tests/ref/fate/ts-small-demux|  2 +-
 tests/ref/fate/ts-timed-id3-demux|  2 +-
 18 files changed, 36 insertions(+), 13 deletions(-)

diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index b53b799227..ef9c9a006c 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -432,6 +432,8 @@
 
 
 
+
+
   
 
   
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index f5c83925b9..916b517d73 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2260,7 +2260,7 @@ static int show_format(AVTextFormatContext *tfc, 
InputFile *ifile)
 {
 AVFormatContext *fmt_ctx = ifile->fmt_ctx;
 int64_t size = fmt_ctx->pb ? avio_size(fmt_ctx->pb) : -1;
-int ret = 0;
+int seekable, ret = 0;
 
 avtext_print_section_header(tfc, NULL, SECTION_ID_FORMAT);
 print_str_validate("filename", fmt_ctx->url);
@@ -2279,6 +2279,19 @@ static int show_format(AVTextFormatContext *tfc, 
InputFile *ifile)
 if (fmt_ctx->bit_rate > 0) print_val("bit_rate", fmt_ctx->bit_rate, 
unit_bit_per_second_str);
 else   print_str_opt("bit_rate", "N/A");
 print_int("probe_score", fmt_ctx->probe_score);
+
+seekable = avformat_query_seekable(fmt_ctx);
+if (seekable > 0) {
+print_int("seekable",  1);
+if (seekable & AVSEEKABLE_PROP_FWDONLY)
+print_int("seek_backward", 0);
+else
+print_int("seek_backward", 1);
+}
+else {
+print_int("seekable",  0);
+print_int("seek_backward", 0);
+}
 if (do_show_format_tags)
 ret = show_tags(tfc, fmt_ctx->metadata, SECTION_ID_FORMAT_TAGS);
 
diff --git a/tests/ref/fate/cavs-demux b/tests/ref/fate/cavs-demux
index b1e2c2fd25..a7f5eda73b 100644
--- a/tests/ref/fate/cavs-demux
+++ b/tests/ref/fate/cavs-demux
@@ -59,4 +59,4 @@ 
packet|codec_type=video|stream_index=0|pts=232|pts_time=1.93|dts=232
 
packet|codec_type=video|stream_index=0|pts=236|pts_time=1.97|dts=236|dts_time=1.97|duration=4|duration_time=0.03|size=83|pos=172252|flags=K__|data_hash=CRC32:a941bdf0
 
packet|codec_type=video|stream_index=0|pts=240|pts_time=2.00|dts=240|dts_time=2.00|duration=4|duration_time=0.03|size=5417|pos=172335|flags=K__|data_hash=CRC32:9d0d503b
 
stream|index=0|codec_name=cavs|profile=unknown|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x|width=1280|height=720|coded_width=1280|coded_height=720|has_b_frames=0|sample_aspect_ratio=N/A|display_aspect_ratio=N/A|pix_fmt=yuv420p|level=-99|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=unspecified|field_order=unknown|refs=1|id=N/A|r_frame_rate=30/1|avg_frame_rate=25/1|time_base=1/120|start_pts=N/A|start_time=N/A|duration_ts=N/A|duration=N/A|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=60|extradata_size=18|extradata_hash=CRC32:1255d52e|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0|disposition:multilayer=0
-format|filename=bunny.mp4|nb_streams=1|nb_programs=0|nb_stream_groups=0|format_name=cavsvideo|start_time=N/A|duration=N/A|size=177752|bit_rate=N/A|probe_score=51
+format|filename=bunny.mp4|nb_streams=1|nb_programs=0|nb_stream_groups=0|format_name=cavsvideo|start_time=N/A|duration=N/A|size=177752|bit_rate=N/A|probe_score=51|seekable=1|seek_backward=1
diff --git a/tests/ref/fate/ffprobe_compact b/tests/ref/fate/ffprobe_compact
index 68b9acf599..c4c0140656 100644
--- a/tests/ref/fate/ffprobe_compact
+++ b/tests/ref/fate/ffprobe_compact
@@ -29,4 +29,4 @@ 
frame|media_type=video|stream_index=2|key_frame=1|pts=6144|pts_time=0.12|pkt
 
stream|index=0|codec_name=pcm_s16le|profile=unknown|codec_type=audio|codec_tag_string=PSD[16]|codec_tag=0x10445350|sample_fmt=s16|sample_rate=44100|channels=1|channel_layo

[FFmpeg-devel] [PATCH v3 1/2] avformat: add avformat_query_seekable

2025-04-16 Thread Gyan Doshi
Utility function to report seekability features for a given input.

Useful for ffprobe and to extend seek possibilities in fftools.
---
v3:
   add some checks for seekability such as
 default stream
 demuxer seek function for NOFILE formats

 doc/APIchanges |  3 ++
 libavformat/avformat.h | 23 +++
 libavformat/seek.c | 64 ++
 libavformat/version.h  |  2 +-
 4 files changed, 91 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..879f56b572 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
 
 API changes, most recent first:
 
+2025-04-xx - xx - lavf 62.1.100 - avformat.h
+  Add avformat_query_seekable().
+
 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
   Add AV_DICT_DEDUP.
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 498c3020a5..295a9784fe 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2338,6 +2338,29 @@ int av_seek_frame(AVFormatContext *s, int stream_index, 
int64_t timestamp,
  */
 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, 
int64_t ts, int64_t max_ts, int flags);
 
+#define AVSEEKABLE_IO_NORMAL   0x0001 ///< I/O is seekable like a 
local file
+#define AVSEEKABLE_IO_PROTOCOL 0x0002 ///< I/O seek is through 
protocol request via avio_seek_time
+#define AVSEEKABLE_VIA_DEMUXER 0x0004 ///< demuxer has a seek function
+#define AVSEEKABLE_VIA_PKTSCAN 0x0008 ///< seek is performed by 
consuming and scanning packet timestamps
+#define AVSEEKABLE_BY_TIME 0x0100 ///< seek target can be a 
timestamp
+#define AVSEEKABLE_BY_BYTE 0x0200 ///< seek target can be in bytes
+#define AVSEEKABLE_BY_FRAME0x0400 ///< seek target can be a frame 
index
+#define AVSEEKABLE_PROP_PTS0x0001 ///< seek target timestamp is 
expected to be PTS
+#define AVSEEKABLE_PROP_FAST   0x0002 ///< demuxer allows fast but 
inaccurate seeking
+#define AVSEEKABLE_PROP_SLOW   0x0004 ///< demuxer instance has no 
index to search within
+#define AVSEEKABLE_PROP_FWDONLY0x0008 ///< set seek will be equal or 
forward of specified seek point
+
+/**
+ * Report if and how a seek can be performed in a given input.
+ *
+ * @param smedia file handle
+ *
+ * @return 0 if no seek can be performed on input,
+ * -1 if the fmt ctx is NULL or is not an input
+ * else return AVSEEKABLE_ bitflags indicating seekability features.
+ */
+int avformat_query_seekable(AVFormatContext *s);
+
 /**
  * Discard all internally buffered data. This can be useful when dealing with
  * discontinuities in the byte stream. Generally works only with formats that
diff --git a/libavformat/seek.c b/libavformat/seek.c
index c0d94371e6..0a012322c0 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -712,6 +712,70 @@ int avformat_seek_file(AVFormatContext *s, int 
stream_index, int64_t min_ts,
 return ret;
 }
 
+int avformat_query_seekable(AVFormatContext *s)
+{
+int stream_index, ret = 0;
+
+if (!s || !s->iformat)
+return -1;
+
+if (s->ctx_flags & AVFMTCTX_UNSEEKABLE)
+return 0;
+
+stream_index = av_find_default_stream_index(s);
+if (stream_index < 0)
+return 0;
+
+if (ffifmt(s->iformat)->read_seek || ffifmt(s->iformat)->read_seek2)
+ret |= AVSEEKABLE_VIA_DEMUXER;
+
+if (ffifmt(s->iformat)->read_timestamp && !(s->iformat->flags & 
AVFMT_NOBINSEARCH))
+ret |= AVSEEKABLE_VIA_PKTSCAN;
+
+if (!(s->iformat->flags & AVFMT_NOTIMESTAMPS))
+ret |= AVSEEKABLE_BY_TIME;
+
+// TODO: incomplete, a few demuxers don't set flag but error out on byte 
seek
+if (!(s->iformat->flags & AVFMT_NO_BYTE_SEEK))
+ret |= AVSEEKABLE_BY_BYTE;
+
+// TODO: no flag for frame seeking. Add flag and enable this check
+if (s->iformat->flags & 0)
+ret |= AVSEEKABLE_BY_FRAME;
+
+if (s->iformat->flags & AVFMT_SEEK_TO_PTS)
+ret |= AVSEEKABLE_PROP_PTS;
+
+// TODO: flag exists but not added to the demuxers which support it
+if (s->iformat->flags & AVFMT_FLAG_FAST_SEEK)
+ret |= AVSEEKABLE_PROP_FAST;
+
+if (!(ret & AVSEEKABLE_VIA_DEMUXER) && ret & AVSEEKABLE_VIA_PKTSCAN)
+ret |= (AVSEEKABLE_PROP_FWDONLY | AVSEEKABLE_PROP_SLOW);
+
+if (!s->pb) {
+if ( !(s->iformat->flags & AVFMT_NOFILE) || !(ret & 
AVSEEKABLE_VIA_DEMUXER) )
+return 0;
+} else {
+if (!s->pb->seekable)
+return 0;
+
+if (s->pb->seekable & AVIO_SEEKABLE_NORMAL)
+ret |= AVSEEKABLE_IO_NORMAL;
+if (s->pb->seekable & AVIO_SEEKABLE_TIME)
+ret |= AVSEEKABLE_IO_PROTOCOL;
+}
+
+if ( !(ret & AVSEEKABLE_VIA_DEMUXER) &&
+ !(ret & AVSEEKABLE_VIA_PKTSCAN) &&
+ !(ret & AVSEEKABLE_BY_BYTE) &&
+ !(ret & A

[FFmpeg-devel] [PATCH] libpostproc/postprocess: Fix deprecating PP_CPU_CAPS_3DNO

2025-04-16 Thread Andreas Rheinhardt
Patch attached.

- Andreas
From 3f7154f2d5fce740d6180c10398f7a1e6ec299d9 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt 
Date: Wed, 16 Apr 2025 14:02:47 +0200
Subject: [PATCH] libpostproc/postprocess: Fix deprecating PP_CPU_CAPS_3DNOW

The wrong version of the patch has been applied:
a) Use the FF_API_ prefix for the deprecation macro.
b) Put it into version_major.h, so that it is automatically
included into postprocess.h, fixing -Wundef warnings.
c) Add APIchanges entry and minor version bump.
d) Add the FF_API boilerplate in version_major.h.

Signed-off-by: Andreas Rheinhardt 
---
 doc/APIchanges  | 3 +++
 libpostproc/postprocess.h   | 2 +-
 libpostproc/version.h   | 4 +---
 libpostproc/version_major.h | 2 ++
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 65bf5a9419..2629f7f014 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
 
 API changes, most recent first:
 
+2025-04-16 - c818c67991 - libpostproc 59.01.100 - postprocess.h
+  Deprecate PP_CPU_CAPS_3DNOW.
+
 2025-04-07 - 19e9a203b7 - lavu 60.01.100 - dict.h
   Add AV_DICT_DEDUP.
 
diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
index 7010c2b51b..d2adb6ccad 100644
--- a/libpostproc/postprocess.h
+++ b/libpostproc/postprocess.h
@@ -87,7 +87,7 @@ void pp_free_context(pp_context *ppContext);
 
 #define PP_CPU_CAPS_MMX   0x8000
 #define PP_CPU_CAPS_MMX2  0x2000
-#if PP_AMD_3DNOW
+#if FF_API_PP_AMD_3DNOW
 #define PP_CPU_CAPS_3DNOW 0x4000
 #endif
 #define PP_CPU_CAPS_ALTIVEC 0x1000
diff --git a/libpostproc/version.h b/libpostproc/version.h
index 5a272630bf..8294f007bd 100644
--- a/libpostproc/version.h
+++ b/libpostproc/version.h
@@ -30,7 +30,7 @@
 
 #include "version_major.h"
 
-#define LIBPOSTPROC_VERSION_MINOR   0
+#define LIBPOSTPROC_VERSION_MINOR   1
 #define LIBPOSTPROC_VERSION_MICRO 100
 
 #define LIBPOSTPROC_VERSION_INT AV_VERSION_INT(LIBPOSTPROC_VERSION_MAJOR, \
@@ -43,6 +43,4 @@
 
 #define LIBPOSTPROC_IDENT   "postproc" AV_STRINGIFY(LIBPOSTPROC_VERSION)
 
-#define PP_AMD_3DNOW   (LIBPOSTPROC_VERSION_MAJOR < 60)
-
 #endif /* POSTPROC_VERSION_H */
diff --git a/libpostproc/version_major.h b/libpostproc/version_major.h
index b40b251a73..1e0825eab1 100644
--- a/libpostproc/version_major.h
+++ b/libpostproc/version_major.h
@@ -28,4 +28,6 @@
 
 #define LIBPOSTPROC_VERSION_MAJOR  59
 
+#define FF_API_PP_AMD_3DNOW   (LIBPOSTPROC_VERSION_MAJOR < 60)
+
 #endif /* POSTPROC_VERSION_MAJOR_H */
-- 
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 2/3] doc/dict2: Add doc and api change for AVDictionary2

2025-04-16 Thread softworkz .



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Michael Niedermayer
> Sent: Mittwoch, 16. April 2025 23:48
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/3] doc/dict2: Add doc and api
> change for AVDictionary2
> 
> Hi softworkz
> 
> I think we should use AI to support us and reduce the workload
> on people.
> I think this here cost you money 

This is part of an ongoing research for a project that is totally 
unrelated to FFmpeg. It wasn't my own money and it wasn't spent 
in order to create an AvDictionary2 for FFmpeg. 

Also, I didn't know that you are working on it, you had written 
that you won't have time. That's why I thought it's a good subject,
being a real-world task and somebody who will be interested in 
something to play with, even though it's just at a prototype level.

I had thought: Michael wants something, but has no time to work on
it - hmm, he will surely be positively surprised to get some code
in that direction.


So I hope all things are cleared up now. I had no bad intentions in
any direction, just the opposite.

sw

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/dvbsubenc: Sanity check num_rects

2025-04-16 Thread Michael Niedermayer
On Wed, Apr 16, 2025 at 11:17:30AM +0200, Andreas Rheinhardt wrote:
> Patches attached.
> 
> - Andreas

>  dvbsubenc.c |3 +++
>  1 file changed, 3 insertions(+)
> 27ce315dbaee02f8c92c12f8c9cd0c8c7edc54fb  
> 0001-avcodec-dvbsubenc-Sanity-check-num_rects.patch
> From b3a4381000d13ac344114dd5f0230c9eae7b32aa Mon Sep 17 00:00:00 2001
> From: Andreas Rheinhardt 
> Date: Wed, 16 Apr 2025 10:23:01 +0200
> Subject: [PATCH 1/2] avcodec/dvbsubenc: Sanity check num_rects
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> It is written as region_id which is a single byte.
> Also fixes a potential (defined) overflow in the num_rects * 6
> multiplication later; this has been found by 김승호 .
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/dvbsubenc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/dvbsubenc.c b/libavcodec/dvbsubenc.c
> index 822e3a5309..8eeac76855 100644
> --- a/libavcodec/dvbsubenc.c
> +++ b/libavcodec/dvbsubenc.c
> @@ -284,6 +284,9 @@ static int dvbsub_encode(AVCodecContext *avctx, uint8_t 
> *outbuf, int buf_size,
>  if (h->num_rects && !h->rects)
>  return AVERROR(EINVAL);
>  
> +if (h->num_rects >= 256)
> +return AVERROR_INVALIDDATA;

should this not be AVERROR(EINVAL); ?

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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 v2] avcodec/webvttdec: strip classes

2025-04-16 Thread Michael Niedermayer
Hi

On Fri, Mar 21, 2025 at 04:55:02PM +0100, Leon Grutters wrote:
> If a supported tag has a class, e.g "" it is ignored entirely;
> so for example "Hello" would be converted to "Hello{\i0}"
> instead of the intended "{\i1}Hello{\i0}".
> 
> Signed-off-by: Leon Grutters 
> ---
>  libavcodec/webvttdec.c | 39 ---
>  1 file changed, 28 insertions(+), 11 deletions(-)

I see no fate tests changing. So it seems theres a lack of tests
maybe you can add some tests while you wait for someone to review
This would avoid future regressions

thx

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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".