Re: [FFmpeg-devel] Add protocol for Android content providers

2024-02-14 Thread Matthieu Bouron
On Thu, Feb 15, 2024 at 12:13:59PM +0800, Zhao Zhili wrote:
> 
> 
> > On Feb 14, 2024, at 06:50, Matthieu Bouron  
> > wrote:
> > 
> > Hi,
> > 
> > On Android, content providers are used for accessing files through shared
> > mechanisms. One typical case would be an app willing to open a video from
> > Google Photos, gallery apps, TikTok, Instagram or some other providers.
> > A content URI looks something like "content://authority/path/id", see:
> > https://developer.android.com/reference/android/content/ContentUris
> > https://developer.android.com/guide/topics/providers/content-provider-basics
> > 
> > It can currently be somehow managed through clumsy means such as using a 
> > "fd:"
> > filename and crafting a special AVOption, which also has the drawback of
> > requiring the third party to carry around opened file descriptors (with the
> > multiple opened file limitations implied). Custom AVIOContexts are also an
> 
> File descriptor is a general abstraction layer, it target more platforms than
> Android specific content provider. Android provided getFd() API since API
> level 12, I guess that’s the default method to deal with content provider in
> native code. It’s a few lines of code to get native fd in Java, but dozens of 
> code
> in C with JNI, which is what this patchset done.
> 
> For multiple opened file limitations issue, they can close the file 
> descriptor after
> open. It’s unlikely to reach the limit in normal case without leak.
> 
> I’m OK to provide this android_content_protocol helper if user requests.

I've been doing this kind of work for 3/4 users (including myself) at this
point and have to do it another time, this is what motivated me to propose
this patchset.

> 
> > option. Both options will have to deal with the JNI though and end users 
> > will
> > have to re-implement the same exact thing.
> 
> User still need to deal with JNI with the new android_content_protocol, more 
> or
> less, it’s unavoidable.

The advantage I see of using this protocol is that the user only need to
call av_jni_set_jvm() + av_jni_set_android_app_ctx() at the start of the
application and FFmpeg will handle the content-uri transparently. This is
especially helpful if the Android application rely on multiple libraries
that in turn rely on FFmpeg to read medias.

> 
> > 
> > This patchset addresses this by adding a content provider protocol, which 
> > has
> > an API fairly similar to fopen. Android 11 appears to provide something
> > transparent within fopen(), but FFmpeg doesn't use it in the file protocol, 
> > and
> > Android < 11 are still widely used.
> > 
> > The first part move the JNI infrastructure from avcodec to avutil (it 
> > remains
> > internally shared, there is little user implication),
> 
> OK. JNI infrastructure should belong to avutil at the first place, so 
> hwcontext_mediacodec
> and so on can use it. Unfortunately for those new avpriv_.

What do you mean by "Unfortunately" ? Would you like to make the JNI API
public ?

[...]
___
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/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Matthieu Bouron
On Wed, Feb 14, 2024 at 11:31:21PM +, Mark Thompson wrote:
> On 13/02/2024 22:50, Matthieu Bouron wrote:
> > This will allow to use the jni utils in libavformat. This will be mostly 
> > useful
> > to add Android content-uri support.
> > 
> > This deprecates avcodec/jni.h functions in favor of the ones from 
> > avutil/jni.h.
> > ---
> >   doc/APIchanges |   6 +
> >   libavcodec/Makefile|   3 +-
> >   libavcodec/jni.c   |  48 +
> >   libavcodec/jni.h   |   8 +
> >   libavcodec/mediacodec.c|   6 +-
> >   libavcodec/mediacodec_surface.c|   6 +-
> >   libavcodec/mediacodec_wrapper.c| 200 ++---
> >   libavcodec/mediacodecdec.c |   3 +-
> >   libavutil/Makefile |   4 +
> >   libavutil/jni.c|  78 
> >   libavutil/jni.h|  46 +
> >   libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
> >   libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
> >   13 files changed, 283 insertions(+), 187 deletions(-)
> >   create mode 100644 libavutil/jni.c
> >   create mode 100644 libavutil/jni.h
> >   rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
> >   rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)
> 
> Why?
> 
> libavformat already depends on libavcodec.

Since both libavformat  and libavcodec will use it, it seems more
logical to put the code in libavutil. It could also benefits
libavutil/hwcontext_mediacodec.

[...]
___
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/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor

2024-02-14 Thread Anton Khirnov
I remember wondering why was this not run as a FATE test.

-- 
Anton Khirnov
___
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] lavc/texturedsp: require explicitly-set frame dimensions

2024-02-14 Thread Connor Worley
This change decouples the frame dimensions from avctx, which is useful
for DXV decoding, and fixes incorrect behavior in the existing
implementation.

Tested with `make fate THREADS=7` and
`make fate THREADS=7 THREAD_TYPE=slice`.

Signed-off-by: Connor Worley 
---
 libavcodec/dds.c |  2 ++
 libavcodec/dxv.c | 19 ++-
 libavcodec/dxvenc.c  |  2 ++
 libavcodec/hapdec.c  |  2 ++
 libavcodec/hapenc.c  |  2 ++
 libavcodec/texturedsp.h  |  1 +
 libavcodec/texturedsp_template.c |  4 ++--
 libavcodec/vbndec.c  |  2 ++
 libavcodec/vbnenc.c  |  2 ++
 9 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dds.c b/libavcodec/dds.c
index 67e2325a2a..89cf225f25 100644
--- a/libavcodec/dds.c
+++ b/libavcodec/dds.c
@@ -636,6 +636,8 @@ static int dds_decode(AVCodecContext *avctx, AVFrame *frame,
 ctx->dec.tex_data.in = gbc->buffer;
 ctx->dec.frame_data.out = frame->data[0];
 ctx->dec.stride = frame->linesize[0];
+ctx->dec.width  = avctx->coded_width;
+ctx->dec.height = avctx->coded_height;
 ff_texturedsp_exec_decompress_threads(avctx, >dec);
 } else if (!ctx->paletted && ctx->bpp == 4 && avctx->pix_fmt == 
AV_PIX_FMT_PAL8) {
 uint8_t *dst = frame->data[0];
diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 2eca14c129..b5553a0c86 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -843,7 +843,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
 {
 DXVContext *ctx = avctx->priv_data;
 GetByteContext *gbc = >gbc;
-AVCodecContext cavctx = *avctx;
 TextureDSPThreadContext texdsp_ctx, ctexdsp_ctx;
 int (*decompress_tex)(AVCodecContext *avctx);
 const char *msgcomp, *msgtext;
@@ -854,9 +853,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
 
 bytestream2_init(gbc, avpkt->data, avpkt->size);
 
-cavctx.coded_height = avctx->coded_height / 2;
-cavctx.coded_width  = avctx->coded_width  / 2;
-
 avctx->pix_fmt = AV_PIX_FMT_RGBA;
 avctx->colorspace = AVCOL_SPC_RGB;
 
@@ -943,7 +939,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
 texdsp_ctx.slice_count  = av_clip(avctx->thread_count, 1,
   avctx->coded_height / TEXTURE_BLOCK_H);
 ctexdsp_ctx.slice_count = av_clip(avctx->thread_count, 1,
-  cavctx.coded_height / TEXTURE_BLOCK_H);
+  avctx->coded_height / 2 / 
TEXTURE_BLOCK_H);
+
 /* New header is 12 bytes long. */
 if (!old_type) {
 version_major = bytestream2_get_byte(gbc) - 1;
@@ -979,8 +976,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
 if (avctx->pix_fmt != AV_PIX_FMT_RGBA) {
 int i;
 
-ctx->ctex_size = cavctx.coded_width  / ctexdsp_ctx.raw_ratio *
- cavctx.coded_height / TEXTURE_BLOCK_H *
+ctx->ctex_size = avctx->coded_width  / 2 / ctexdsp_ctx.raw_ratio *
+ avctx->coded_height / 2 / TEXTURE_BLOCK_H *
  ctexdsp_ctx.tex_ratio;
 
 ctx->op_size[0] = avctx->coded_width * avctx->coded_height / 16;
@@ -1007,6 +1004,10 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame 
*frame,
 if (ret < 0)
 return ret;
 
+texdsp_ctx.width   = avctx->coded_width;
+texdsp_ctx.height  = avctx->coded_height;
+ctexdsp_ctx.width  = avctx->coded_width  / 2;
+ctexdsp_ctx.height = avctx->coded_height / 2;
 switch (tag) {
 case DXV_FMT_YG10:
 /* BC5 texture with alpha in the second half of each block */
@@ -1022,13 +1023,13 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame 
*frame,
 ctexdsp_ctx.tex_data.in= ctx->ctex_data;
 ctexdsp_ctx.frame_data.out = frame->data[2];
 ctexdsp_ctx.stride = frame->linesize[2];
-ret = ff_texturedsp_exec_decompress_threads(, _ctx);
+ret = ff_texturedsp_exec_decompress_threads(avctx, _ctx);
 if (ret < 0)
 return ret;
 ctexdsp_ctx.tex_data.in= ctx->ctex_data + ctexdsp_ctx.tex_ratio / 
2;
 ctexdsp_ctx.frame_data.out = frame->data[1];
 ctexdsp_ctx.stride = frame->linesize[1];
-ret = ff_texturedsp_exec_decompress_threads(, _ctx);
+ret = ff_texturedsp_exec_decompress_threads(avctx, _ctx);
 if (ret < 0)
 return ret;
 /* fallthrough */
diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c
index bb2c2f8526..85cbca2be8 100644
--- a/libavcodec/dxvenc.c
+++ b/libavcodec/dxvenc.c
@@ -233,6 +233,8 @@ static int dxv_encode(AVCodecContext *avctx, AVPacket *pkt,
 ctx->enc.tex_data.out = ctx->tex_data;
 ctx->enc.frame_data.in = frame->data[0];
 ctx->enc.stride = frame->linesize[0];
+ctx->enc.width  = avctx->width;
+ctx->enc.height = avctx->height;
 

Re: [FFmpeg-devel] Add protocol for Android content providers

2024-02-14 Thread Zhao Zhili


> On Feb 14, 2024, at 06:50, Matthieu Bouron  wrote:
> 
> Hi,
> 
> On Android, content providers are used for accessing files through shared
> mechanisms. One typical case would be an app willing to open a video from
> Google Photos, gallery apps, TikTok, Instagram or some other providers.
> A content URI looks something like "content://authority/path/id", see:
> https://developer.android.com/reference/android/content/ContentUris
> https://developer.android.com/guide/topics/providers/content-provider-basics
> 
> It can currently be somehow managed through clumsy means such as using a "fd:"
> filename and crafting a special AVOption, which also has the drawback of
> requiring the third party to carry around opened file descriptors (with the
> multiple opened file limitations implied). Custom AVIOContexts are also an

File descriptor is a general abstraction layer, it target more platforms than
Android specific content provider. Android provided getFd() API since API
level 12, I guess that’s the default method to deal with content provider in
native code. It’s a few lines of code to get native fd in Java, but dozens of 
code
in C with JNI, which is what this patchset done.

For multiple opened file limitations issue, they can close the file descriptor 
after
open. It’s unlikely to reach the limit in normal case without leak.

I’m OK to provide this android_content_protocol helper if user requests.

> option. Both options will have to deal with the JNI though and end users will
> have to re-implement the same exact thing.

User still need to deal with JNI with the new android_content_protocol, more or
less, it’s unavoidable.

> 
> This patchset addresses this by adding a content provider protocol, which has
> an API fairly similar to fopen. Android 11 appears to provide something
> transparent within fopen(), but FFmpeg doesn't use it in the file protocol, 
> and
> Android < 11 are still widely used.
> 
> The first part move the JNI infrastructure from avcodec to avutil (it remains
> internally shared, there is little user implication),

OK. JNI infrastructure should belong to avutil at the first place, so 
hwcontext_mediacodec
and so on can use it. Unfortunately for those new avpriv_.

> and then the URLProtocol
> is added, along with a few cleanups.
> 
> Regards,
> 
> -- 
> Matthieu
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

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

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


[FFmpeg-devel] [PATCH] avformat/libsrt: Remove manually free AV_OPT_TYPE_STRING

2024-02-14 Thread Zhao Zhili
From: Zhao Zhili 

Signed-off-by: Zhao Zhili 
---
 libavformat/libsrt.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index 56acb6e741..a1d732f841 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -674,9 +674,6 @@ static int libsrt_open(URLContext *h, const char *uri, int 
flags)
 return 0;
 
 err:
-av_freep(>smoother);
-av_freep(>streamid);
-av_freep(>passphrase);
 srt_cleanup();
 return ret;
 }
-- 
2.42.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 07/10] fftools/ffmpeg_filter: refactor setting input timebase

2024-02-14 Thread Michael Niedermayer
On Wed, Feb 14, 2024 at 07:24:32PM +0100, Anton Khirnov wrote:
> Treat it analogously to stream parameters like format/dimensions/etc.
> This is functionally different from previous code in 2 ways:
> * for non-CFR video, the frame timebase (set by the decoder) is used
>   rather than the demuxer timebase
> * for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the
>   subtitle decoding API
> 
> These changes should avoid unnecessary and potentially lossy timestamp
> conversions from decoder timebase into the demuxer one.
> 
> Changes the timebases used in sub2video tests.
> ---
>  fftools/ffmpeg_filter.c   |  17 ++-
>  tests/ref/fate/sub2video_basic| 182 +-
>  tests/ref/fate/sub2video_time_limited |   8 +-
>  3 files changed, 106 insertions(+), 101 deletions(-)

breaks:

./ffmpeg -i 
\[a-s\]_full_metal_panic_fumoffu_-_01_-_the_man_from_the_south_-_a_hostage_with_no_compromises__rs2_\[1080p_bd-rip\]\[BBB48A25\].mkv
  -filter_complex '[0:s:1]scale=800:600' -t 15 -qscale 2 -bitexact -y 
/tmp/file-pgstest2.avi
...
Press [q] to stop, [?] for help
[aac @ 0x55dcd4a5a940] This stream seems to incorrectly report its last channel 
as LFE[3], mapping to LFE[0]
[mpeg4 @ 0x55dcd4a5b780] timebase 1/100 not supported by MPEG 4 standard, 
the maximum admitted value for the timebase denominator is 65535
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Error while opening encoder - maybe incorrect 
parameters such as bit_rate, rate, width or height.
[fc#0 @ 0x55dcd4a37a00] Error sending frames to consumers: Invalid argument
[fc#0 @ 0x55dcd4a37a00] Task finished with error code: -22 (Invalid argument)
[fc#0 @ 0x55dcd4a37a00] Terminating thread with return code -22 (Invalid 
argument)
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Could not open encoder before EOF
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Task finished with error code: -22 (Invalid 
argument)
[vost#0:0/mpeg4 @ 0x55dcd4a5b2c0] Terminating thread with return code -22 
(Invalid argument)
[libmp3lame @ 0x55dcd4a5ca80] Trying to remove 1152 samples, but the queue is 
empty
[out#0/avi @ 0x55dcd4a7f680] Nothing was written into output file, because at 
least one of its streams received no packets.
frame=0 fps=0.0 q=0.0 Lsize=   0KiB time=N/A bitrate=N/A speed=N/A
Conversion failed!

vs.

Press [q] to stop, [?] for help
[aac @ 0x55b416e87e00] This stream seems to incorrectly report its last channel 
as LFE[3], mapping to LFE[0]
Output #0, avi, to '/tmp/file-pgstest2.avi':
  Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p(progressive), 800x600, 
q=2-31, 200 kb/s, 1k tbn
  Metadata:
encoder : Lavc mpeg4
  Side data:
cpb: bitrate max/min/avg: 0/0/20 buffer size: 0 vbv_delay: N/A
  Stream #0:1(eng): Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, fltp 
(default)
  Metadata:
title   : AAC
encoder : Lavc libmp3lame
[libmp3lame @ 0x55b416e76640] Trying to remove 1152 samples, but the queue is 
empty
[out#0/avi @ 0x55b416e7fec0] video:496KiB audio:235KiB subtitle:0KiB other 
streams:0KiB global headers:0KiB muxing overhead: 51.412292%
frame=  360 fps=0.0 q=2.0 Lsize=1108KiB time=00:00:14.97 bitrate= 
605.9kbits/s dup=0 drop=16 speed=44.9x


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

Never trust a computer, one day, it may think you are the virus. -- Compn


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] av_tx_init: accept NULL scale for RDFT

2024-02-14 Thread Lynne
Feb 14, 2024, 21:45 by pr...@xvid.org:

> Make av_tx_init() agree with documentation:
>
>  * Real to complex and complex to real DFTs.
>  * For the float and int32 variants, the scale type is 'float', while for
>  * the double variant, it's a 'double'. If scale is NULL, 1.0 will be used
>  * as a default.
> ---
>  libavutil/tx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/tx.c b/libavutil/tx.c
> index d6740071b9..cc360cff31 100644
> --- a/libavutil/tx.c
> +++ b/libavutil/tx.c
> @@ -914,9 +914,9 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, 
> enum AVTXType type,
>  if (!(flags & AV_TX_INPLACE))
>  flags |= FF_TX_OUT_OF_PLACE;
>  
> -if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT)))
> +if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) 
> || (type == AV_TX_FLOAT_RDFT) || (AV_TX_INT32_RDFT)))
>  scale = _scale_f;
> -else if (!scale && (type == AV_TX_DOUBLE_MDCT))
> +else if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == 
> AV_TX_DOUBLE_RDFT)))
>  scale = _scale_d;
>  
>  ret = ff_tx_init_subtx(, type, flags, NULL, len, inv, scale);
>

LGTM
thnx
___
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/9] libavcodec: add amfdec.

2024-02-14 Thread Mark Thompson

On 14/02/2024 01:55, Dmitrii Ovchinnikov wrote:

From: Evgeny Pavlov 

Added AMF based h264, hevc, av1 decoders.
Co-authored-by: Dmitrii Ovchinnikov 
---
  libavcodec/Makefile |   4 +-
  libavcodec/allcodecs.c  |   3 +
  libavcodec/amfdec.c | 667 
  libavcodec/amfdec.h |  75 +
  libavcodec/h264_slice.c |   3 +
  libavcodec/h264dec.c|   3 +
  libavcodec/hwconfig.h   |   2 +
  7 files changed, 755 insertions(+), 2 deletions(-)
  create mode 100644 libavcodec/amfdec.c
  create mode 100644 libavcodec/amfdec.h

...
+
+static int amf_decode_init(AVCodecContext *avctx)
+{
+AvAmfDecoderContext *ctx = avctx->priv_data;
+int ret;
+enum AVPixelFormat pix_fmts[3] = {
+AV_PIX_FMT_AMF,
+avctx->pix_fmt,
+AV_PIX_FMT_NONE };
+
+ret = ff_get_format(avctx, pix_fmts);
+if (ret < 0) {
+avctx->pix_fmt = AV_PIX_FMT_NONE;
+}


I think you've misunderstood how decoder setup works.  AVCodecContext.pix_fmt 
happens to be set to an initial value in some cases which use libavformat 
(including the ffmpeg utility), but there is no requirement on the user to do 
so (see the doxy).  Also all of the format information can change at any moment 
mid-stream (consider adaptive streaming scenarios).

It is therefore necessary for the decoder to parse the input and determine the 
intended format before calling the get_format callback, and to do that again 
whenever the format changes.  Calling it once at the beginning does not work at 
all.


...
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 8464a0b34c..d11821194f 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -864,6 +864,9 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, 
int force_callback)
  #if CONFIG_H264_NVDEC_HWACCEL
  *fmt++ = AV_PIX_FMT_CUDA;
  #endif
+#if CONFIG_H264_AMFDEC_HWACCEL
+*fmt++ = AV_PIX_FMT_AMF;
+#endif
  #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
  if (h->avctx->colorspace != AVCOL_SPC_RGB)
  *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX;
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 9f5893c512..7a2c9eecef 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -1137,6 +1137,9 @@ const FFCodec ff_h264_decoder = {
  #if CONFIG_H264_NVDEC_HWACCEL
 HWACCEL_NVDEC(h264),
  #endif
+#if CONFIG_H264_AMFDEC_HWACCEL
+   HWACCEL_AMFDEC(h264),
+#endif
  #if CONFIG_H264_VAAPI_HWACCEL
 HWACCEL_VAAPI(h264),
  #endif


I don't see any acceleration support here at all, this is entirely an offload 
decoder.

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH] avformat/libsrt: Fix srt:// URL parsing

2024-02-14 Thread Marton Balint




On Mon, 12 Feb 2024, Ingo Oppermann wrote:


Add missing NULL check and use ff_urldecode for string query
parameters.


Will apply, thanks.

Marton



Signed-off-by: Ingo Oppermann 
---
libavformat/libsrt.c | 12 +---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
index cd8f5b1e7d..d549aea1f7 100644
--- a/libavformat/libsrt.c
+++ b/libavformat/libsrt.c
@@ -32,6 +32,7 @@
#include "network.h"
#include "os_support.h"
#include "url.h"
+#include "urldecode.h"

/* This is for MPEG-TS and it's a default SRTO_PAYLOADSIZE for SRTT_LIVE (8 TS 
packets) */
#ifndef SRT_LIVE_DEFAULT_PAYLOAD_SIZE
@@ -547,7 +548,11 @@ static int libsrt_open(URLContext *h, const char *uri, int 
flags)
}
if (av_find_info_tag(buf, sizeof(buf), "passphrase", p)) {
av_freep(>passphrase);
-s->passphrase = av_strndup(buf, strlen(buf));
+s->passphrase = ff_urldecode(buf, 1);
+if (!s->passphrase) {
+ret = AVERROR(ENOMEM);
+goto err;
+}
}
#if SRT_VERSION_VALUE >= 0x010302
if (av_find_info_tag(buf, sizeof(buf), "enforced_encryption", p)) {
@@ -632,7 +637,7 @@ static int libsrt_open(URLContext *h, const char *uri, int 
flags)
}
if (av_find_info_tag(buf, sizeof(buf), "streamid", p)) {
av_freep(>streamid);
-s->streamid = av_strdup(buf);
+s->streamid = ff_urldecode(buf, 1);
if (!s->streamid) {
ret = AVERROR(ENOMEM);
goto err;
@@ -640,7 +645,7 @@ static int libsrt_open(URLContext *h, const char *uri, int 
flags)
}
if (av_find_info_tag(buf, sizeof(buf), "smoother", p)) {
av_freep(>smoother);
-s->smoother = av_strdup(buf);
+s->smoother = ff_urldecode(buf, 1);
if(!s->smoother) {
ret = AVERROR(ENOMEM);
goto err;
@@ -671,6 +676,7 @@ static int libsrt_open(URLContext *h, const char *uri, int 
flags)
err:
av_freep(>smoother);
av_freep(>streamid);
+av_freep(>passphrase);
srt_cleanup();
return ret;
}
--
2.39.3 (Apple Git-145)

___
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 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Mark Thompson

On 13/02/2024 22:50, Matthieu Bouron wrote:

This will allow to use the jni utils in libavformat. This will be mostly useful
to add Android content-uri support.

This deprecates avcodec/jni.h functions in favor of the ones from avutil/jni.h.
---
  doc/APIchanges |   6 +
  libavcodec/Makefile|   3 +-
  libavcodec/jni.c   |  48 +
  libavcodec/jni.h   |   8 +
  libavcodec/mediacodec.c|   6 +-
  libavcodec/mediacodec_surface.c|   6 +-
  libavcodec/mediacodec_wrapper.c| 200 ++---
  libavcodec/mediacodecdec.c |   3 +-
  libavutil/Makefile |   4 +
  libavutil/jni.c|  78 
  libavutil/jni.h|  46 +
  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
  13 files changed, 283 insertions(+), 187 deletions(-)
  create mode 100644 libavutil/jni.c
  create mode 100644 libavutil/jni.h
  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)


Why?

libavformat already depends on libavcodec.

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH] lavc/texturedsp: require explicitly-set frame dimensions

2024-02-14 Thread Marton Balint




On Sun, 11 Feb 2024, Connor Worley wrote:


This change decouples the frame dimensions from avctx, which is useful
for DXV decoding, and fixes incorrect behavior in the existing
implementation.


Keep in mind that avctx->coded_width/height can change on a per-frame 
basis. So most likely it is better to assign width/height right before 
the call to ff_texturedsp_exec*


Regards,
Marton



Tested with `make fate THREADS=7` and
`make fate THREADS=7 THREAD_TYPE=slice`.

Signed-off-by: Connor Worley 
---
libavcodec/dds.c |  3 +++
libavcodec/dxv.c | 19 ++-
libavcodec/dxvenc.c  |  3 +++
libavcodec/hapdec.c  |  5 +
libavcodec/hapenc.c  |  3 +++
libavcodec/texturedsp.h  |  1 +
libavcodec/texturedsp_template.c |  4 ++--
libavcodec/vbndec.c  |  3 +++
libavcodec/vbnenc.c  |  3 +++
9 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/libavcodec/dds.c b/libavcodec/dds.c
index 67e2325a2a..83f51be802 100644
--- a/libavcodec/dds.c
+++ b/libavcodec/dds.c
@@ -339,6 +339,9 @@ static int parse_pixel_format(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Unsupported %s fourcc.\n", 
av_fourcc2str(fourcc));
return AVERROR_INVALIDDATA;
}
+
+ctx->dec.width  = avctx->coded_width;
+ctx->dec.height = avctx->coded_height;
} else if (ctx->paletted) {
if (bpp == 8) {
avctx->pix_fmt = AV_PIX_FMT_PAL8;
diff --git a/libavcodec/dxv.c b/libavcodec/dxv.c
index 2eca14c129..4eaa6dc224 100644
--- a/libavcodec/dxv.c
+++ b/libavcodec/dxv.c
@@ -843,7 +843,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
{
DXVContext *ctx = avctx->priv_data;
GetByteContext *gbc = >gbc;
-AVCodecContext cavctx = *avctx;
TextureDSPThreadContext texdsp_ctx, ctexdsp_ctx;
int (*decompress_tex)(AVCodecContext *avctx);
const char *msgcomp, *msgtext;
@@ -854,9 +853,6 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,

bytestream2_init(gbc, avpkt->data, avpkt->size);

-cavctx.coded_height = avctx->coded_height / 2;
-cavctx.coded_width  = avctx->coded_width  / 2;
-
avctx->pix_fmt = AV_PIX_FMT_RGBA;
avctx->colorspace = AVCOL_SPC_RGB;

@@ -943,7 +939,12 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame 
*frame,
texdsp_ctx.slice_count  = av_clip(avctx->thread_count, 1,
  avctx->coded_height / TEXTURE_BLOCK_H);
ctexdsp_ctx.slice_count = av_clip(avctx->thread_count, 1,
-  cavctx.coded_height / TEXTURE_BLOCK_H);
+  avctx->coded_height / 2 / 
TEXTURE_BLOCK_H);
+texdsp_ctx.width   = avctx->coded_width;
+texdsp_ctx.height  = avctx->coded_height;
+ctexdsp_ctx.width  = avctx->coded_width  / 2;
+ctexdsp_ctx.height = avctx->coded_height / 2;
+
/* New header is 12 bytes long. */
if (!old_type) {
version_major = bytestream2_get_byte(gbc) - 1;
@@ -979,8 +980,8 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame *frame,
if (avctx->pix_fmt != AV_PIX_FMT_RGBA) {
int i;

-ctx->ctex_size = cavctx.coded_width  / ctexdsp_ctx.raw_ratio *
- cavctx.coded_height / TEXTURE_BLOCK_H *
+ctx->ctex_size = avctx->coded_width  / 2 / ctexdsp_ctx.raw_ratio *
+ avctx->coded_height / 2 / TEXTURE_BLOCK_H *
 ctexdsp_ctx.tex_ratio;

ctx->op_size[0] = avctx->coded_width * avctx->coded_height / 16;
@@ -1022,13 +1023,13 @@ static int dxv_decode(AVCodecContext *avctx, AVFrame 
*frame,
ctexdsp_ctx.tex_data.in= ctx->ctex_data;
ctexdsp_ctx.frame_data.out = frame->data[2];
ctexdsp_ctx.stride = frame->linesize[2];
-ret = ff_texturedsp_exec_decompress_threads(, _ctx);
+ret = ff_texturedsp_exec_decompress_threads(avctx, _ctx);
if (ret < 0)
return ret;
ctexdsp_ctx.tex_data.in= ctx->ctex_data + ctexdsp_ctx.tex_ratio / 2;
ctexdsp_ctx.frame_data.out = frame->data[1];
ctexdsp_ctx.stride = frame->linesize[1];
-ret = ff_texturedsp_exec_decompress_threads(, _ctx);
+ret = ff_texturedsp_exec_decompress_threads(avctx, _ctx);
if (ret < 0)
return ret;
/* fallthrough */
diff --git a/libavcodec/dxvenc.c b/libavcodec/dxvenc.c
index bb2c2f8526..62ac812226 100644
--- a/libavcodec/dxvenc.c
+++ b/libavcodec/dxvenc.c
@@ -298,6 +298,9 @@ static av_cold int dxv_init(AVCodecContext *avctx)
ctx->enc.tex_ratio;
ctx->enc.slice_count = av_clip(avctx->thread_count, 1, avctx->height / 
TEXTURE_BLOCK_H);

+ctx->enc.width  = avctx->width;
+ctx->enc.height = avctx->height;
+
ctx->tex_data = av_malloc(ctx->tex_size);
if (!ctx->tex_data) {
return AVERROR(ENOMEM);
diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c
index 

Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Matthieu Bouron
On Wed, Feb 14, 2024 at 07:18:04PM +0100, Michael Niedermayer wrote:
> On Tue, Feb 13, 2024 at 11:50:09PM +0100, Matthieu Bouron wrote:
> > This will allow to use the jni utils in libavformat. This will be mostly 
> > useful
> > to add Android content-uri support.
> > 
> > This deprecates avcodec/jni.h functions in favor of the ones from 
> > avutil/jni.h.
> > ---
> >  doc/APIchanges |   6 +
> >  libavcodec/Makefile|   3 +-
> >  libavcodec/jni.c   |  48 +
> >  libavcodec/jni.h   |   8 +
> >  libavcodec/mediacodec.c|   6 +-
> >  libavcodec/mediacodec_surface.c|   6 +-
> >  libavcodec/mediacodec_wrapper.c| 200 ++---
> >  libavcodec/mediacodecdec.c |   3 +-
> >  libavutil/Makefile |   4 +
> >  libavutil/jni.c|  78 
> >  libavutil/jni.h|  46 +
> >  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
> >  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
> >  13 files changed, 283 insertions(+), 187 deletions(-)
> >  create mode 100644 libavutil/jni.c
> >  create mode 100644 libavutil/jni.h
> >  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
> >  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)
> 
> this breaks build
> 
>  make
> CClibavutil/jni.o
> libavutil/jni.c:68:5: error: no previous prototype for ‘av_jni_set_java_vm’ 
> [-Werror=missing-prototypes]
>  int av_jni_set_java_vm(void *vm, void *log_ctx)
>  ^~
> libavutil/jni.c:73:7: error: no previous prototype for ‘av_jni_get_java_vm’ 
> [-Werror=missing-prototypes]
>  void *av_jni_get_java_vm(void *log_ctx)
>^~
> cc1: some warnings being treated as errors
> ffbuild/common.mak:81: recipe for target 'libavutil/jni.o' failed
> make: *** [libavutil/jni.o] Error 1

Thanks, new patch attached.

[...]
>From 5b6a127143d8a3d111f7bef1a3e3bc9aab60a8ea Mon Sep 17 00:00:00 2001
From: Matthieu Bouron 
Date: Mon, 12 Feb 2024 18:33:41 +0100
Subject: [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

This will allow to use the jni utils in libavformat. This will be mostly useful
to add Android content-uri support.

This deprecates avcodec/jni.h functions in favor of the ones from avutil/jni.h.
---
 doc/APIchanges |   6 +
 libavcodec/Makefile|   3 +-
 libavcodec/jni.c   |  49 +
 libavcodec/jni.h   |   8 +
 libavcodec/mediacodec.c|   6 +-
 libavcodec/mediacodec_surface.c|   6 +-
 libavcodec/mediacodec_wrapper.c| 200 ++---
 libavcodec/mediacodecdec.c |   3 +-
 libavutil/Makefile |   4 +
 libavutil/jni.c|  78 
 libavutil/jni.h|  46 +
 libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
 libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
 13 files changed, 284 insertions(+), 187 deletions(-)
 create mode 100644 libavutil/jni.c
 create mode 100644 libavutil/jni.h
 rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
 rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)

diff --git a/doc/APIchanges b/doc/APIchanges
index 221fea30c2..45611ea7ea 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,12 @@ The last version increases of all libraries were on 2023-02-09
 
 API changes, most recent first:
 
+2024-02-xx - xx - lavu 58.39.100 - jni.h
+  Add av_jni_set_jvm() and av_jni_get_jvm().
+
+2024-02-xx - xx - lavc 60.40.100 - jni.h
+  Deprecate av_jni_set_java_vm() and av_jni_get_java_vm().
+
 2024-02-xx - xx - lavu 58.38.100 - channel_layout.h
   Add av_channel_layout_retype().
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 470d7cb9b1..f8584d8dfd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -117,7 +117,7 @@ OBJS-$(CONFIG_IIRFILTER)   += iirfilter.o
 OBJS-$(CONFIG_INFLATE_WRAPPER) += zlib_wrapper.o
 OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4data.o
 OBJS-$(CONFIG_IVIDSP)  += ivi_dsp.o
-OBJS-$(CONFIG_JNI) += ffjni.o jni.o
+OBJS-$(CONFIG_JNI) += jni.o
 OBJS-$(CONFIG_JPEGTABLES)  += jpegtables.o
 OBJS-$(CONFIG_LCMS2)   += fflcms2.o
 OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o
@@ -1269,7 +1269,6 @@ SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
 SKIPHEADERS-$(CONFIG_D3D12VA)  += d3d12va_decode.h
 SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h
-SKIPHEADERS-$(CONFIG_JNI)  += ffjni.h
 SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h
 

[FFmpeg-devel] [PATCH 7/7] swscale/tests/swscale: Add help text

2024-02-14 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 32e1f96be2b..cf8d04de898 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -437,6 +437,25 @@ int main(int argc, char **argv)
 return -1;
 
 for (i = 1; i < argc; i += 2) {
+if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) {
+fprintf(stderr,
+"swscale [options...]\n"
+"   -help\n"
+"   This text\n"
+"   -ref \n"
+"   Uses file as reference to compae tests againsts. 
Tests that have become worse will contain the string worse or WORSE\n"
+"   -p \n"
+"   The percentage of tests or comparissions to 
perform. Doing all tests will take long and generate over a hundread MB text 
output\n"
+"   It is often convenient to perform a random 
subset\n"
+"   -dst \n"
+"   Only test the specified destination pixel format\n"
+"   -src \n"
+"   Only test the specified source pixel format\n"
+"   -cpuflags \n"
+"   Uses the specified cpuflags in teh tests\n"
+);
+goto error;
+}
 if (argv[i][0] != '-' || i + 1 == argc)
 goto bad_option;
 if (!strcmp(argv[i], "-ref")) {
@@ -469,7 +488,7 @@ int main(int argc, char **argv)
 prob = atof(argv[i + 1]);
 } else {
 bad_option:
-fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
+fprintf(stderr, "bad option or argument missing (%s) see -help\n", 
argv[i]);
 goto error;
 }
 }
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 6/7] swscale/tests/swscale: Highlight cases that worsened

2024-02-14 Thread Michael Niedermayer
also highlight cases that worsened alot in uppercase

Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 68434fb7baf..32e1f96be2b 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -285,6 +285,15 @@ static int doTest(const uint8_t * const ref[4], int 
refStride[4], int w, int h,
 av_free(out[i]);
 }
 
+if(r){
+if(ssdY>r->ssdY*1.02+1 || ssdU>r->ssdU*1.02+1 || ssdV>r->ssdV*1.02+1|| 
ssdA>r->ssdA*1.02+1)
+printf("WORSE SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
+r->ssdY, r->ssdU, r->ssdV, r->ssdA);
+else if(ssdY>r->ssdY || ssdU>r->ssdU || ssdV>r->ssdV|| ssdA>r->ssdA)
+printf("worse SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"",
+r->ssdY, r->ssdU, r->ssdV, r->ssdA);
+}
+
 printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 5/7] swscale/tests/swscale: Allow comparing a subset of cases to a reference file

2024-02-14 Thread Michael Niedermayer
Testing all cases exhaustively is slow

Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 07d0af4377e..68434fb7baf 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -33,6 +33,7 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/lfg.h"
+#include "libavutil/sfc64.h"
 
 #include "libswscale/swscale.h"
 
@@ -56,6 +57,9 @@ static av_always_inline int isALPHA(enum AVPixelFormat 
pix_fmt)
 return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
 }
 
+static double prob = 1;
+FFSFC64 prng_state;
+
 static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
int stride1, int stride2, int w, int h)
 {
@@ -117,6 +121,9 @@ static int doTest(const uint8_t * const ref[4], int 
refStride[4], int w, int h,
 uint32_t crc = 0;
 int res  = 0;
 
+if (ff_sfc64_get(_state) > UINT64_MAX * prob)
+return 0;
+
 if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
 struct SwsContext *srcContext = NULL;
 int p;
@@ -449,6 +456,8 @@ int main(int argc, char **argv)
 fprintf(stderr, "invalid pixel format %s\n", argv[i + 1]);
 return -1;
 }
+} else if (!strcmp(argv[i], "-p")) {
+prob = atof(argv[i + 1]);
 } else {
 bad_option:
 fprintf(stderr, "bad option or argument missing (%s)\n", argv[i]);
@@ -456,6 +465,8 @@ bad_option:
 }
 }
 
+ff_sfc64_init(_state, 0, 0, 0, 12);
+
 sws = sws_getContext(W / 12, H / 12, AV_PIX_FMT_RGB32, W, H,
  AV_PIX_FMT_YUVA420P, SWS_BILINEAR, NULL, NULL, NULL);
 
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 4/7] swscale/tests/swscale: Test a wider range of flag combinations

2024-02-14 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index facdbbae481..07d0af4377e 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -296,8 +296,10 @@ static void selfTest(const uint8_t * const ref[4], int 
refStride[4],
  enum AVPixelFormat srcFormat_in,
  enum AVPixelFormat dstFormat_in)
 {
-const int flags[] = { SWS_FAST_BILINEAR, SWS_BILINEAR, SWS_BICUBIC,
-  SWS_X, SWS_POINT, SWS_AREA, 0 };
+const int flags[] = { SWS_FAST_BILINEAR,
+  SWS_BILINEAR, SWS_BICUBIC,
+  SWS_X|SWS_BITEXACT   , SWS_POINT  , 
SWS_AREA|SWS_ACCURATE_RND,
+  SWS_BICUBIC|SWS_FULL_CHR_H_INT|SWS_FULL_CHR_H_INP, 
0};
 const int srcW   = w;
 const int srcH   = h;
 const int dstW[] = { srcW - srcW / 3, srcW, srcW + srcW / 3, 0 };
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 3/7] swscale/tests/swscale: Compute chroma and alpha between gray and opaque frames too

2024-02-14 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 6792fcaa3dc..facdbbae481 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -71,6 +71,21 @@ static uint64_t getSSD(const uint8_t *src1, const uint8_t 
*src2,
 return ssd;
 }
 
+static uint64_t getSSD0(int ref, const uint8_t *src1, int stride1,
+int w, int h)
+{
+int x, y;
+uint64_t ssd = 0;
+
+for (y = 0; y < h; y++) {
+for (x = 0; x < w; x++) {
+int d = src1[x + y * stride1] - ref;
+ssd += d * d;
+}
+}
+return ssd;
+}
+
 struct Results {
 uint64_t ssdY;
 uint64_t ssdU;
@@ -239,9 +254,17 @@ static int doTest(const uint8_t * const ref[4], int 
refStride[4], int w, int h,
   (w + 1) >> 1, (h + 1) >> 1);
 ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
   (w + 1) >> 1, (h + 1) >> 1);
+} else {
+ssdU = getSSD0(128, out[1], refStride[1],
+  (w + 1) >> 1, (h + 1) >> 1);
+ssdV = getSSD0(128, out[2], refStride[2],
+  (w + 1) >> 1, (h + 1) >> 1);
 }
-if (isALPHA(srcFormat) && isALPHA(dstFormat))
+if (isALPHA(srcFormat) && isALPHA(dstFormat)) {
 ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
+} else {
+ssdA = getSSD0(0xFF, out[3], refStride[3], w, h);
+}
 
 ssdY /= w * h;
 ssdU /= w * h / 4;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 2/7] swscale/tests/swscale: Split sws_getContext()

2024-02-14 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index f853bc4c913..6792fcaa3dc 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -30,6 +30,7 @@
 #include "libavutil/mem.h"
 #include "libavutil/avutil.h"
 #include "libavutil/crc.h"
+#include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/lfg.h"
 
@@ -165,10 +166,26 @@ static int doTest(const uint8_t * const ref[4], int 
refStride[4], int w, int h,
 }
 }
 
-dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
-flags, NULL, NULL, NULL);
+dstContext = sws_alloc_context();
 if (!dstContext) {
-fprintf(stderr, "Failed to get %s ---> %s\n",
+fprintf(stderr, "Failed to alloc %s ---> %s\n",
+desc_src->name, desc_dst->name);
+res = -1;
+goto end;
+}
+
+av_opt_set_int(dstContext, "sws_flags",  flags, 0);
+av_opt_set_int(dstContext, "srcw",   srcW, 0);
+av_opt_set_int(dstContext, "srch",   srcH, 0);
+av_opt_set_int(dstContext, "dstw",   dstW, 0);
+av_opt_set_int(dstContext, "dsth",   dstH, 0);
+av_opt_set_int(dstContext, "src_format", srcFormat, 0);
+av_opt_set_int(dstContext, "dst_format", dstFormat, 0);
+av_opt_set(dstContext, "alphablend", "none", 0);
+
+if (sws_init_context(dstContext, NULL, NULL) < 0) {
+sws_freeContext(dstContext);
+fprintf(stderr, "Failed to init %s ---> %s\n",
 desc_src->name, desc_dst->name);
 res = -1;
 goto end;
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH 1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor

2024-02-14 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libswscale/tests/swscale.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index 6c38041ddb8..f853bc4c913 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -48,12 +48,12 @@
 (!(isGray(x)|| \
(x) == AV_PIX_FMT_MONOBLACK || \
(x) == AV_PIX_FMT_MONOWHITE))
-#define isALPHA(x) \
-((x) == AV_PIX_FMT_BGR32   || \
- (x) == AV_PIX_FMT_BGR32_1 || \
- (x) == AV_PIX_FMT_RGB32   || \
- (x) == AV_PIX_FMT_RGB32_1 || \
- (x) == AV_PIX_FMT_YUVA420P)
+
+static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
+return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
+}
 
 static uint64_t getSSD(const uint8_t *src1, const uint8_t *src2,
int stride1, int stride2, int w, int h)
-- 
2.17.1

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

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


[FFmpeg-devel] [PATCH] {avcodec, tests}: rename the bundled Mesa AV1 vulkan video headers

2024-02-14 Thread Jan Ekström
This together with adjusting the inclusion define allows for the
build to not fail with latest Vulkan-Headers that contain the
stabilized Vulkan AV1 decoding definitions.

Compilation fails currently as the AV1 header is getting included
via hwcontext_vulkan.h ->  -> vulkan_core.h, which
finally includes vk_video/vulkan_video_codec_av1std.h and the decode
header, leading to the bundled header to never defining anything
due to the inclusion define being the same.

This fix is imperfect, as it leads to additional re-definition
warnings for things such as
VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION. , but it is
not clear how to otherwise have the bundled version trump the
actually standardized one for a short-term compilation fix.
---
 libavcodec/Makefile   | 4 ++--
 libavcodec/vulkan_video.h | 4 ++--
 ...v1std_decode.h => vulkan_video_codec_av1std_decode_mesa.h} | 4 ++--
 ..._video_codec_av1std.h => vulkan_video_codec_av1std_mesa.h} | 4 ++--
 tests/ref/fate/source | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename libavcodec/{vulkan_video_codec_av1std_decode.h => 
vulkan_video_codec_av1std_decode_mesa.h} (89%)
 rename libavcodec/{vulkan_video_codec_av1std.h => 
vulkan_video_codec_av1std_mesa.h} (99%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 470d7cb9b1..09ae5270b3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1262,7 +1262,7 @@ SKIPHEADERS+= %_tablegen.h
  \
   aacenc_quantization.h \
   aacenc_quantization_misc.h\
   bitstream_template.h  \
-  vulkan_video_codec_av1std.h   \
+  vulkan_video_codec_av1std_mesa.h \
   $(ARCH)/vpx_arith.h  \
 
 SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
@@ -1285,7 +1285,7 @@ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h
 SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h 
vaapi_encode.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
-SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan.h vulkan_video.h 
vulkan_decode.h vulkan_video_codec_av1std_decode.h
+SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan.h vulkan_video.h 
vulkan_decode.h vulkan_video_codec_av1std_decode_mesa.h
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h 
v4l2_m2m.h
 SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h
index b28e3fe0bd..51f44dd543 100644
--- a/libavcodec/vulkan_video.h
+++ b/libavcodec/vulkan_video.h
@@ -23,8 +23,8 @@
 #include "vulkan.h"
 
 #include 
-#include "vulkan_video_codec_av1std.h"
-#include "vulkan_video_codec_av1std_decode.h"
+#include "vulkan_video_codec_av1std_mesa.h"
+#include "vulkan_video_codec_av1std_decode_mesa.h"
 
 #define CODEC_VER_MAJ(ver) (ver >> 22)
 #define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1))
diff --git a/libavcodec/vulkan_video_codec_av1std_decode.h 
b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h
similarity index 89%
rename from libavcodec/vulkan_video_codec_av1std_decode.h
rename to libavcodec/vulkan_video_codec_av1std_decode_mesa.h
index a697c00593..e2f37b4e6e 100644
--- a/libavcodec/vulkan_video_codec_av1std_decode.h
+++ b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_
-#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1
+#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_
+#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_ 1
 
 /*
 ** This header is NOT YET generated from the Khronos Vulkan XML API Registry.
diff --git a/libavcodec/vulkan_video_codec_av1std.h 
b/libavcodec/vulkan_video_codec_av1std_mesa.h
similarity index 99%
rename from libavcodec/vulkan_video_codec_av1std.h
rename to libavcodec/vulkan_video_codec_av1std_mesa.h
index c46236c457..c91589eee2 100644
--- a/libavcodec/vulkan_video_codec_av1std.h
+++ b/libavcodec/vulkan_video_codec_av1std_mesa.h
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_
-#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1
+#ifndef VULKAN_VIDEO_CODEC_AV1STD_MESA_H_
+#define VULKAN_VIDEO_CODEC_AV1STD_MESA_H_ 1
 
 /*
 ** This header is NOT YET generated from the Khronos Vulkan XML API Registry.
diff --git a/tests/ref/fate/source b/tests/ref/fate/source
index c575789dd5..a025200318 100644
--- a/tests/ref/fate/source
+++ b/tests/ref/fate/source
@@ -23,8 +23,8 @@ compat/djgpp/math.h
 compat/float/float.h
 compat/float/limits.h
 libavcodec/bitstream_template.h

Re: [FFmpeg-devel] [PATCH 1/9] libavutil: add hwcontext_amf.

2024-02-14 Thread Mark Thompson

On 14/02/2024 01:55, Dmitrii Ovchinnikov wrote:

Adds hwcontext_amf, which allows to use shared AMF
context for the encoder, decoder and AMF-based filters,
without copy to the host memory.
It will also allow you to use some optimizations in
the interaction of components (for example, SAV) and make a more
manageable and optimal setup for using GPU devices with AMF
in the case of a fully AMF pipeline.
It will be a significant performance uplift when full AMF pipeline
with filters is used.

We also plan to add Compression artefact removal filter in near feature.
---
  libavutil/Makefile |   3 +
  libavutil/hwcontext.c  |   4 +
  libavutil/hwcontext.h  |   1 +
  libavutil/hwcontext_amf.c  | 580 +
  libavutil/hwcontext_amf.h  | 105 ++
  libavutil/hwcontext_internal.h |   1 +
  libavutil/pixdesc.c|   4 +
  libavutil/pixfmt.h |   4 +
  8 files changed, 702 insertions(+)
  create mode 100644 libavutil/hwcontext_amf.c
  create mode 100644 libavutil/hwcontext_amf.h

...
diff --git a/libavutil/hwcontext_amf.h b/libavutil/hwcontext_amf.h
new file mode 100644
index 00..0161b9a29c
--- /dev/null
+++ b/libavutil/hwcontext_amf.h
@@ -0,0 +1,105 @@
+/*
+ * 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
+ */
+
+
+#ifndef AVUTIL_HWCONTEXT_AMF_H
+#define AVUTIL_HWCONTEXT_AMF_H
+#include 
+#include 
+#include 
+#include "pixfmt.h"
+
+#include "libavformat/avformat.h"
+#include "libavutil/hwcontext.h"
+
+#define FFMPEG_AMF_WRITER_ID L"ffmpeg_amf"
+
+typedef struct AmfTraceWriter {
+AMFTraceWriterVtbl  *vtbl;
+void*avctx;
+void*avcl;
+} AmfTraceWriter;
+
+typedef struct AVAMFDeviceContextInternal {
+amf_handle  library; ///< handle to DLL library
+AMFFactory *factory; ///< pointer to AMF factory
+AMFDebug   *debug;   ///< pointer to AMF debug interface
+AMFTrace   *trace;   ///< pointer to AMF trace interface
+
+amf_uint64  version; ///< version of AMF runtime
+AMFContext *context; ///< AMF context
+AMF_MEMORY_TYPE mem_type;
+} AVAMFDeviceContextInternal;
+
+/**
+ * This struct is allocated as AVHWDeviceContext.hwctx
+ */
+
+typedef struct AVAMFDeviceContext {
+AVBufferRef*internal;
+} AVAMFDeviceContext;
+
+typedef struct AMFFramesContext {
+AMFSurface * surfaces;
+intnb_surfaces;
+} AMFFramesContext;
+
+/**
+* Error handling helper
+*/
+#define AMF_RETURN_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
+if (!(exp)) { \
+av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
+return ret_value; \
+}
+
+#define AMF_GOTO_FAIL_IF_FALSE(avctx, exp, ret_value, /*message,*/ ...) \
+if (!(exp)) { \
+av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \
+ret = ret_value; \
+goto fail; \
+}
+
+#define AMF_TIME_BASE_Q  (AVRational){1, AMF_SECOND}
+
+typedef struct FormatMap {
+enum AVPixelFormat   av_format;
+enum AMF_SURFACE_FORMAT  amf_format;
+} FormatMap;
+
+extern const FormatMap format_map[];
+enum AMF_SURFACE_FORMAT av_amf_av_to_amf_format(enum AVPixelFormat fmt);
+enum AVPixelFormat av_amf_to_av_format(enum AMF_SURFACE_FORMAT fmt);
+extern AmfTraceWriter av_amf_trace_writer;
+
+int av_amf_context_init(AVAMFDeviceContextInternal* internal, void* avcl);
+int av_amf_load_library(AVAMFDeviceContextInternal* internal,  void* avcl);
+int av_amf_create_context(  AVAMFDeviceContextInternal * internal,
+void* avcl,
+const char *device,
+AVDictionary *opts, int flags);
+int av_amf_context_internal_create(AVAMFDeviceContextInternal * internal,
+void* avcl,
+const char *device,
+AVDictionary *opts, int flags);
+void av_amf_context_internal_free(void *opaque, uint8_t *data);
+int av_amf_context_derive(AVAMFDeviceContextInternal * internal,
+  AVHWDeviceContext *child_device_ctx, 
AVDictionary *opts,
+  int flags);
+
+#endif /* AVUTIL_HWCONTEXT_AMF_H */


We need to sort out the 

[FFmpeg-devel] [PATCH] av_tx_init: accept NULL scale for RDFT

2024-02-14 Thread Peter Ross
Make av_tx_init() agree with documentation:

 * Real to complex and complex to real DFTs.
 * For the float and int32 variants, the scale type is 'float', while for
 * the double variant, it's a 'double'. If scale is NULL, 1.0 will be used
 * as a default.
---
 libavutil/tx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/tx.c b/libavutil/tx.c
index d6740071b9..cc360cff31 100644
--- a/libavutil/tx.c
+++ b/libavutil/tx.c
@@ -914,9 +914,9 @@ av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, 
enum AVTXType type,
 if (!(flags & AV_TX_INPLACE))
 flags |= FF_TX_OUT_OF_PLACE;
 
-if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT)))
+if (!scale && ((type == AV_TX_FLOAT_MDCT) || (type == AV_TX_INT32_MDCT) || 
(type == AV_TX_FLOAT_RDFT) || (AV_TX_INT32_RDFT)))
 scale = _scale_f;
-else if (!scale && (type == AV_TX_DOUBLE_MDCT))
+else if (!scale && ((type == AV_TX_DOUBLE_MDCT) || (type == 
AV_TX_DOUBLE_RDFT)))
 scale = _scale_d;
 
 ret = ff_tx_init_subtx(, type, flags, NULL, len, inv, scale);
-- 
2.43.0

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


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

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


Re: [FFmpeg-devel] [PATCH 3/3] avcodec/pngenc: write eXIf chunks

2024-02-14 Thread Andreas Rheinhardt
Leo Izen:
> Write EXIF metadata exposed AV_FRAME_DATA_EXIF as an eXIf chunk
> to PNG files, if present.
> 
> Signed-off-by: Leo Izen 
> ---
>  libavcodec/pngenc.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
> index 50689cb50c..a302c879da 100644
> --- a/libavcodec/pngenc.c
> +++ b/libavcodec/pngenc.c
> @@ -413,6 +413,10 @@ static int encode_headers(AVCodecContext *avctx, const 
> AVFrame *pict)
>  }
>  }
>  
> +side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_EXIF);
> +if (side_data)
> +png_write_chunk(>bytestream, MKTAG('e', 'X', 'I', 'f'), 
> side_data->data, FFMIN(side_data->size, INT_MAX));
> +
>  side_data = av_frame_get_side_data(pict, AV_FRAME_DATA_ICC_PROFILE);
>  if ((ret = png_write_iccp(s, side_data)))
>  return ret;

If I see this correctly, then these patches can lead to a situation
where an input packet has rotation metadata in exif which gets exported
twice -- as displaymatrix and as exif metadata side data. If the user
changes the displaymatrix (e.g. applies the transformation to the image
data and removes the displaymatrix side data before reencoding), the
exif data (that the user would probably not be aware of) would still be
there and get propagated into the output, corrupting it.

- 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 3/3] avcodec/pngenc: write eXIf chunks

2024-02-14 Thread Michael Niedermayer
On Tue, Feb 13, 2024 at 04:24:56PM -0500, Leo Izen wrote:
> Write EXIF metadata exposed AV_FRAME_DATA_EXIF as an eXIf chunk
> to PNG files, if present.
> 
> Signed-off-by: Leo Izen 
> ---
>  libavcodec/pngenc.c | 4 
>  1 file changed, 4 insertions(+)

This seems to break:

--- ./tests/ref/fate/cover-art-mp3-id3v2-remux  2024-02-14 19:33:50.756012174 
+0100
+++ tests/data/fate/cover-art-mp3-id3v2-remux   2024-02-14 19:36:59.150052682 
+0100
@@ -1,5 +1,5 @@
-94946f0efd5f9bb0061ac1fbff7d731f *tests/data/fate/cover-art-mp3-id3v2-remux.mp3
-399346 tests/data/fate/cover-art-mp3-id3v2-remux.mp3
+0643e306430fbadeb1c89da6ab36a303 *tests/data/fate/cover-art-mp3-id3v2-remux.mp3
+399414 tests/data/fate/cover-art-mp3-id3v2-remux.mp3
 #tb 0: 1/14112000
 #media_type 0: audio
 #codec_id 0: mp3
@@ -23,7 +23,7 @@
 0,-353590,-353590,   368640,  417, 0x15848290, S=1,   10
 1,  0,  0,0,   208350, 0x291b44d1
 2,  0,  0,0,15760, 0x71d5c418
-3,  0,  0,0,   165671, 0x7c1c8070
+3,  0,  0,0,   165739, 0x2e108b69
 0,  15050,  15050,   368640,  418, 0x46f684a4
 0, 383690, 383690,   368640,  418, 0x46f684a4
 0, 752330, 752330,   368640,  418, 0x46f684a4
Test cover-art-mp3-id3v2-remux failed. Look at 
tests/data/fate/cover-art-mp3-id3v2-remux.err for details.
tests/Makefile:318: recipe for target 'fate-cover-art-mp3-id3v2-remux' failed
make: *** [fate-cover-art-mp3-id3v2-remux] Error 1

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

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus


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 09/10] fftools/ffmpeg: move subtitle helpers to ffmpeg_dec, their only user

2024-02-14 Thread Anton Khirnov
---
 fftools/ffmpeg.c | 120 ---
 fftools/ffmpeg.h |   3 --
 fftools/ffmpeg_dec.c | 120 +++
 3 files changed, 120 insertions(+), 123 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 035210a8e9..3ee7b26d26 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -640,126 +640,6 @@ static void print_report(int is_last_report, int64_t 
timer_start, int64_t cur_ti
 first_report = 0;
 }
 
-int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
-{
-int ret = AVERROR_BUG;
-AVSubtitle tmp = {
-.format = src->format,
-.start_display_time = src->start_display_time,
-.end_display_time = src->end_display_time,
-.num_rects = 0,
-.rects = NULL,
-.pts = src->pts
-};
-
-if (!src->num_rects)
-goto success;
-
-if (!(tmp.rects = av_calloc(src->num_rects, sizeof(*tmp.rects
-return AVERROR(ENOMEM);
-
-for (int i = 0; i < src->num_rects; i++) {
-AVSubtitleRect *src_rect = src->rects[i];
-AVSubtitleRect *dst_rect;
-
-if (!(dst_rect = tmp.rects[i] = av_mallocz(sizeof(*tmp.rects[0] {
-ret = AVERROR(ENOMEM);
-goto cleanup;
-}
-
-tmp.num_rects++;
-
-dst_rect->type  = src_rect->type;
-dst_rect->flags = src_rect->flags;
-
-dst_rect->x = src_rect->x;
-dst_rect->y = src_rect->y;
-dst_rect->w = src_rect->w;
-dst_rect->h = src_rect->h;
-dst_rect->nb_colors = src_rect->nb_colors;
-
-if (src_rect->text)
-if (!(dst_rect->text = av_strdup(src_rect->text))) {
-ret = AVERROR(ENOMEM);
-goto cleanup;
-}
-
-if (src_rect->ass)
-if (!(dst_rect->ass = av_strdup(src_rect->ass))) {
-ret = AVERROR(ENOMEM);
-goto cleanup;
-}
-
-for (int j = 0; j < 4; j++) {
-// SUBTITLE_BITMAP images are special in the sense that they
-// are like PAL8 images. first pointer to data, second to
-// palette. This makes the size calculation match this.
-size_t buf_size = src_rect->type == SUBTITLE_BITMAP && j == 1 ?
-  AVPALETTE_SIZE :
-  src_rect->h * src_rect->linesize[j];
-
-if (!src_rect->data[j])
-continue;
-
-if (!(dst_rect->data[j] = av_memdup(src_rect->data[j], buf_size))) 
{
-ret = AVERROR(ENOMEM);
-goto cleanup;
-}
-dst_rect->linesize[j] = src_rect->linesize[j];
-}
-}
-
-success:
-*dst = tmp;
-
-return 0;
-
-cleanup:
-avsubtitle_free();
-
-return ret;
-}
-
-static void subtitle_free(void *opaque, uint8_t *data)
-{
-AVSubtitle *sub = (AVSubtitle*)data;
-avsubtitle_free(sub);
-av_free(sub);
-}
-
-int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
-{
-AVBufferRef *buf;
-AVSubtitle *sub;
-int ret;
-
-if (copy) {
-sub = av_mallocz(sizeof(*sub));
-ret = sub ? copy_av_subtitle(sub, subtitle) : AVERROR(ENOMEM);
-if (ret < 0) {
-av_freep();
-return ret;
-}
-} else {
-sub = av_memdup(subtitle, sizeof(*subtitle));
-if (!sub)
-return AVERROR(ENOMEM);
-memset(subtitle, 0, sizeof(*subtitle));
-}
-
-buf = av_buffer_create((uint8_t*)sub, sizeof(*sub),
-   subtitle_free, NULL, 0);
-if (!buf) {
-avsubtitle_free(sub);
-av_freep();
-return AVERROR(ENOMEM);
-}
-
-frame->buf[0] = buf;
-
-return 0;
-}
-
 static void print_stream_maps(void)
 {
 av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1fdc835723..295f470a62 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -709,9 +709,6 @@ int init_simple_filtergraph(InputStream *ist, OutputStream 
*ost,
 Scheduler *sch, unsigned sch_idx_enc);
 int init_complex_filtergraph(FilterGraph *fg);
 
-int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src);
-int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy);
-
 /**
  * Get our axiliary frame data attached to the frame, allocating it
  * if needed.
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index bf41a44f1f..1cfa15b943 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -371,6 +371,126 @@ static int video_frame_process(DecoderPriv *dp, AVFrame 
*frame)
 return 0;
 }
 
+static int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
+{
+int ret = AVERROR_BUG;
+AVSubtitle tmp = {
+.format = src->format,
+.start_display_time = src->start_display_time,
+.end_display_time = 

[FFmpeg-devel] [PATCH 06/10] fftools/ffmpeg_filter: pass framerate through InputFilterOptions

2024-02-14 Thread Anton Khirnov
Rather than read it directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
 fftools/ffmpeg.h| 10 --
 fftools/ffmpeg_demux.c  | 10 +++---
 fftools/ffmpeg_filter.c |  9 +++--
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 9942342f03..1fdc835723 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -253,6 +253,7 @@ typedef struct OptionsContext {
 enum IFilterFlags {
 IFILTER_FLAG_AUTOROTATE = (1 << 0),
 IFILTER_FLAG_REINIT = (1 << 1),
+IFILTER_FLAG_CFR= (1 << 2),
 };
 
 typedef struct InputFilterOptions {
@@ -261,6 +262,13 @@ typedef struct InputFilterOptions {
 
 uint8_t*name;
 
+/* When IFILTER_FLAG_CFR is set, the stream is guaranteed to be CFR with
+ * this framerate.
+ *
+ * Otherwise, this is an estimate that should not be relied upon to be
+ * accurate */
+AVRational  framerate;
+
 int sub2video_width;
 int sub2video_height;
 
@@ -365,8 +373,6 @@ typedef struct InputStream {
 Decoder  *decoder;
 const AVCodec*dec;
 
-AVRationalframerate_guessed;
-
 /* framerate forced with -r */
 AVRationalframerate;
 #if FFMPEG_OPT_TOP
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 317e27e294..e543c4215c 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -992,7 +992,13 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, 
int is_simple,
 if (ret < 0)
 return ret;
 
-if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) {
+if (ist->framerate.num > 0 && ist->framerate.den > 0) {
+opts->framerate = ist->framerate;
+opts->flags |= IFILTER_FLAG_CFR;
+} else
+opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL);
+} else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
 /* Compute the size of the canvas for the subtitles stream.
If the subtitles codecpar has set a size, use it. Otherwise use the
maximum dimensions of the video streams in the same file. */
@@ -1359,8 +1365,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
 MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
 #endif
 
-ist->framerate_guessed = av_guess_frame_rate(ic, st, NULL);
-
 break;
 case AVMEDIA_TYPE_AUDIO: {
 int guess_layout_max = INT_MAX;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 56aa3edd78..dc65b441a6 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1486,7 +1486,7 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
 const AVPixFmtDescriptor *desc;
 InputStream *ist = ifp->ist;
-AVRational fr = ist->framerate;
+AVRational fr = ifp->opts.framerate;
 AVRational sar;
 AVBPrint args;
 char name[255];
@@ -1495,14 +1495,11 @@ static int configure_input_video_filter(FilterGraph 
*fg, AVFilterGraph *graph,
 if (!par)
 return AVERROR(ENOMEM);
 
-if (!fr.num)
-fr = ist->framerate_guessed;
-
 if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
 sub2video_prepare(ifp);
 
-ifp->time_base =  ist->framerate.num ? av_inv_q(ist->framerate) :
-   ist->st->time_base;
+ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ?
+ av_inv_q(ifp->opts.framerate) : ist->st->time_base;
 
 sar = ifp->sample_aspect_ratio;
 if(!sar.den)
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH 07/10] fftools/ffmpeg_filter: refactor setting input timebase

2024-02-14 Thread Anton Khirnov
Treat it analogously to stream parameters like format/dimensions/etc.
This is functionally different from previous code in 2 ways:
* for non-CFR video, the frame timebase (set by the decoder) is used
  rather than the demuxer timebase
* for sub2video, AV_TIME_BASE_Q is used, which is hardcoded by the
  subtitle decoding API

These changes should avoid unnecessary and potentially lossy timestamp
conversions from decoder timebase into the demuxer one.

Changes the timebases used in sub2video tests.
---
 fftools/ffmpeg_filter.c   |  17 ++-
 tests/ref/fate/sub2video_basic| 182 +-
 tests/ref/fate/sub2video_time_limited |   8 +-
 3 files changed, 106 insertions(+), 101 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index dc65b441a6..a13b2ccf95 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -148,6 +148,8 @@ typedef struct InputFilterPriv {
 
 // fallback parameters to use when no input is ever sent
 struct {
+AVRational  time_base;
+
 int format;
 
 int width;
@@ -697,6 +699,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
palettes for all rectangles are identical or compatible */
 ifp->format = AV_PIX_FMT_RGB32;
 
+ifp->time_base = AV_TIME_BASE_Q;
+
 av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n",
ifp->width, ifp->height);
 }
@@ -1485,7 +1489,6 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 AVFilterContext *last_filter;
 const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
 const AVPixFmtDescriptor *desc;
-InputStream *ist = ifp->ist;
 AVRational fr = ifp->opts.framerate;
 AVRational sar;
 AVBPrint args;
@@ -1498,9 +1501,6 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 if (ifp->type_src == AVMEDIA_TYPE_SUBTITLE)
 sub2video_prepare(ifp);
 
-ifp->time_base = (ifp->opts.flags & IFILTER_FLAG_CFR) ?
- av_inv_q(ifp->opts.framerate) : ist->st->time_base;
-
 sar = ifp->sample_aspect_ratio;
 if(!sar.den)
 sar = (AVRational){0,1};
@@ -1591,8 +1591,6 @@ static int configure_input_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 char name[255];
 int ret, pad_idx = 0;
 
-ifp->time_base = (AVRational){ 1, ifp->sample_rate };
-
 av_bprint_init(, 0, AV_BPRINT_SIZE_AUTOMATIC);
 av_bprintf(, "time_base=%d/%d:sample_rate=%d:sample_fmt=%s",
ifp->time_base.num, ifp->time_base.den,
@@ -1821,6 +1819,8 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, 
const AVCodecContext *dec)
 {
 InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
 
+ifp->fallback.time_base = dec->pkt_timebase;
+
 if (dec->codec_type == AVMEDIA_TYPE_VIDEO) {
 ifp->fallback.format = dec->pix_fmt;
 ifp->fallback.width  = dec->width;
@@ -1852,6 +1852,10 @@ static int ifilter_parameters_from_frame(InputFilter 
*ifilter, const AVFrame *fr
 if (ret < 0)
 return ret;
 
+ifp->time_base = (ifp->type == AVMEDIA_TYPE_AUDIO)? (AVRational){ 1, 
frame->sample_rate } :
+ (ifp->opts.flags & IFILTER_FLAG_CFR) ? 
av_inv_q(ifp->opts.framerate) :
+ frame->time_base;
+
 ifp->format  = frame->format;
 
 ifp->width   = frame->width;
@@ -2541,6 +2545,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter 
*ifilter,
 ifp->sample_aspect_ratio= ifp->fallback.sample_aspect_ratio;
 ifp->color_space= ifp->fallback.color_space;
 ifp->color_range= ifp->fallback.color_range;
+ifp->time_base  = ifp->fallback.time_base;
 
 ret = av_channel_layout_copy(>ch_layout,
  >fallback.ch_layout);
diff --git a/tests/ref/fate/sub2video_basic b/tests/ref/fate/sub2video_basic
index a6eb1a34ea..2e4dcb625e 100644
--- a/tests/ref/fate/sub2video_basic
+++ b/tests/ref/fate/sub2video_basic
@@ -1,95 +1,95 @@
-#tb 0: 1/1000
+#tb 0: 1/100
 #media_type 0: video
 #codec_id 0: rawvideo
 #dimensions 0: 720x480
 #sar 0: 0/1
-0, 132499, 132499,0,  1382400, 0x
-0, 132499, 132499,0,  1382400, 0x8c93c2ba
-0, 137459, 137459,0,  1382400, 0x
-0, 147355, 147355,0,  1382400, 0xb02e32ca
-0, 152088, 152088,0,  1382400, 0x
-0, 180797, 180797,0,  1382400, 0x83b71116
-0, 183357, 183357,0,  1382400, 0x
-0, 183433, 183433,0,  1382400, 0x85547fd1
-0, 185799, 185799,0,  1382400, 0x
-0, 185909, 185909,0,  1382400, 0x
-0, 185910, 185910,0,  1382400, 

[FFmpeg-devel] [PATCH 08/10] fftools/ffmpeg_filter: drop unused InputFilterPriv.ist

2024-02-14 Thread Anton Khirnov
Outside of ifilter_bind_ist(), there are no longer any assumptions about
about filter inputs being fed by an InputStream.
---
 fftools/ffmpeg_filter.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index a13b2ccf95..dcd08dbc36 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -109,8 +109,6 @@ typedef struct InputFilterPriv {
 
 AVFilterContext *filter;
 
-InputStream *ist;
-
 // used to hold submitted input
 AVFrame *frame;
 
@@ -124,6 +122,7 @@ typedef struct InputFilterPriv {
 // same as type otherwise
 enum AVMediaType type_src;
 
+int bound;
 int eof;
 
 // parameters configured for this input
@@ -665,7 +664,8 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
 FilterGraphPriv *fgp = fgp_from_fg(ifilter->graph);
 int ret, dec_idx;
 
-av_assert0(!ifp->ist);
+av_assert0(!ifp->bound);
+ifp->bound = 1;
 
 if (ifp->type != ist->par->codec_type &&
 !(ifp->type == AVMEDIA_TYPE_VIDEO && ist->par->codec_type == 
AVMEDIA_TYPE_SUBTITLE)) {
@@ -674,7 +674,6 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
 return AVERROR(EINVAL);
 }
 
-ifp->ist = ist;
 ifp->type_src= ist->st->codecpar->codec_type;
 
 dec_idx = ist_filter_add(ist, ifilter, 
filtergraph_is_simple(ifilter->graph),
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH 10/10] fftools/ffmpeg: cosmetics, vertically align structs

2024-02-14 Thread Anton Khirnov
---
 fftools/ffmpeg_dec.c|  38 ++---
 fftools/ffmpeg_demux.c  |  68 +++
 fftools/ffmpeg_filter.c | 120 
 fftools/ffmpeg_mux.h|  66 +++---
 4 files changed, 146 insertions(+), 146 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 1cfa15b943..769ae36296 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -35,20 +35,20 @@
 #include "thread_queue.h"
 
 typedef struct DecoderPriv {
-Decoder  dec;
+Decoder dec;
 
-AVCodecContext  *dec_ctx;
+AVCodecContext *dec_ctx;
 
-AVFrame *frame;
-AVPacket*pkt;
+AVFrame*frame;
+AVPacket   *pkt;
 
 // override output video sample aspect ratio with this value
-AVRational   sar_override;
+AVRational  sar_override;
 
-AVRational   framerate_in;
+AVRational  framerate_in;
 
 // a combination of DECODER_FLAG_*, provided to dec_open()
-int  flags;
+int flags;
 
 enum AVPixelFormat  hwaccel_pix_fmt;
 enum HWAccelID  hwaccel_id;
@@ -58,22 +58,22 @@ typedef struct DecoderPriv {
 // pts/estimated duration of the last decoded frame
 // * in decoder timebase for video,
 // * in last_frame_tb (may change during decoding) for audio
-int64_t last_frame_pts;
-int64_t last_frame_duration_est;
-AVRational  last_frame_tb;
-int64_t last_filter_in_rescale_delta;
-int last_frame_sample_rate;
+int64_t last_frame_pts;
+int64_t last_frame_duration_est;
+AVRational  last_frame_tb;
+int64_t last_filter_in_rescale_delta;
+int last_frame_sample_rate;
 
 /* previous decoded subtitles */
-AVFrame *sub_prev[2];
-AVFrame *sub_heartbeat;
+AVFrame*sub_prev[2];
+AVFrame*sub_heartbeat;
 
-Scheduler  *sch;
-unsignedsch_idx;
+Scheduler  *sch;
+unsignedsch_idx;
 
-void   *log_parent;
-charlog_name[32];
-char   *parent_name;
+void   *log_parent;
+charlog_name[32];
+char   *parent_name;
 } DecoderPriv;
 
 static DecoderPriv *dp_from_dec(Decoder *d)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index e543c4215c..d5a3dbc1d2 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -40,41 +40,41 @@
 #include "libavformat/avformat.h"
 
 typedef struct DemuxStream {
-InputStream ist;
+InputStream  ist;
 
 // name used for logging
-char log_name[32];
+char log_name[32];
 
-int sch_idx_stream;
-int sch_idx_dec;
+int  sch_idx_stream;
+int  sch_idx_dec;
 
-double ts_scale;
+double   ts_scale;
 
 /* non zero if the packets must be decoded in 'raw_fifo', see 
DECODING_FOR_* */
-int decoding_needed;
+int  decoding_needed;
 #define DECODING_FOR_OST1
 #define DECODING_FOR_FILTER 2
 
 /* true if stream data should be discarded */
-int discard;
+int  discard;
 
 // scheduler returned EOF for this stream
-int finished;
+int  finished;
 
-int streamcopy_needed;
-int have_sub2video;
-int reinit_filters;
+int  streamcopy_needed;
+int  have_sub2video;
+int  reinit_filters;
 
-int wrap_correction_done;
-int saw_first_ts;
+int  wrap_correction_done;
+int  saw_first_ts;
 ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
-int64_t first_dts;
+int64_t  first_dts;
 
 /* predicted dts of the next packet read for this stream or (when there are
  * several frames in a packet) of the next frame in current packet (in 
AV_TIME_BASE units) */
-int64_t   next_dts;
+int64_t  next_dts;
 ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
-int64_t   dts;
+int64_t  dts;
 
 const AVCodecDescriptor *codec_desc;
 
@@ -82,45 +82,45 @@ typedef struct DemuxStream {
 DecoderOpts  dec_opts;
 char dec_name[16];
 
-AVBSFContext *bsf;
+AVBSFContext*bsf;
 
 /* number of packets successfully read for this stream */
-uint64_t nb_packets;
+uint64_t nb_packets;
 // combined size of all the packets read
-uint64_t data_size;
+uint64_t data_size;
 } DemuxStream;
 
 typedef struct Demuxer {
-InputFile f;
+InputFile f;
 
 // name used for logging
-char 

[FFmpeg-devel] [PATCH 05/10] fftools/ffmpeg_filter: pass autorotate/reinit flags through InputFilterOptions

2024-02-14 Thread Anton Khirnov
Rather than read them directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
 fftools/ffmpeg.h| 10 --
 fftools/ffmpeg_demux.c  |  8 ++--
 fftools/ffmpeg_filter.c |  5 +++--
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 6db7b8a9c4..9942342f03 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -250,6 +250,11 @@ typedef struct OptionsContext {
 SpecifierOptList mux_stats_fmt;
 } OptionsContext;
 
+enum IFilterFlags {
+IFILTER_FLAG_AUTOROTATE = (1 << 0),
+IFILTER_FLAG_REINIT = (1 << 1),
+};
+
 typedef struct InputFilterOptions {
 int64_t trim_start_us;
 int64_t trim_end_us;
@@ -258,6 +263,9 @@ typedef struct InputFilterOptions {
 
 int sub2video_width;
 int sub2video_height;
+
+// a combination of IFILTER_FLAG_*
+unsignedflags;
 } InputFilterOptions;
 
 typedef struct InputFilter {
@@ -381,8 +389,6 @@ typedef struct InputStream {
  */
 struct OutputStream **outputs;
 intnb_outputs;
-
-int reinit_filters;
 } InputStream;
 
 typedef struct InputFile {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 87ed8225c2..317e27e294 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -63,6 +63,7 @@ typedef struct DemuxStream {
 
 int streamcopy_needed;
 int have_sub2video;
+int reinit_filters;
 
 int wrap_correction_done;
 int saw_first_ts;
@@ -1033,6 +1034,9 @@ int ist_filter_add(InputStream *ist, InputFilter 
*ifilter, int is_simple,
 if (!opts->name)
 return AVERROR(ENOMEM);
 
+opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ist->autorotate) |
+   IFILTER_FLAG_REINIT * !!(ds->reinit_filters);
+
 return ds->sch_idx_dec;
 }
 
@@ -1309,8 +1313,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
 if (ret < 0)
 return ret;
 
-ist->reinit_filters = -1;
-MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
+ds->reinit_filters = -1;
+MATCH_PER_STREAM_OPT(reinit_filters, i, ds->reinit_filters, ic, st);
 
 ist->user_set_discard = AVDISCARD_NONE;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d182f3ab2e..56aa3edd78 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1534,7 +1534,8 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 av_assert0(desc);
 
 // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
-if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
+if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
+!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
 int32_t *displaymatrix = ifp->displaymatrix;
 double theta;
 
@@ -2614,7 +2615,7 @@ static int send_frame(FilterGraph *fg, FilterGraphThread 
*fgt,
 } else if (ifp->displaymatrix_present)
 need_reinit |= MATRIX_CHANGED;
 
-if (!ifp->ist->reinit_filters && fgt->graph)
+if (!(ifp->opts.flags & IFILTER_FLAG_REINIT) && fgt->graph)
 need_reinit = 0;
 
 if (!!ifp->hw_frames_ctx != !!frame->hw_frames_ctx ||
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH 01/10] fftools/ffmpeg_filter: stop taking display matrix from global side data

2024-02-14 Thread Anton Khirnov
It should never be necessary now that decoders propagate global side
data to frames.
---
 fftools/ffmpeg_filter.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 38ddd1963a..ed62e1d8ec 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1523,16 +1523,9 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 
 // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
 if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
-const AVPacketSideData *sd = NULL;
 int32_t *displaymatrix = ifp->displaymatrix;
 double theta;
 
-if (!ifp->displaymatrix_present)
-sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data,
- ist->st->codecpar->nb_coded_side_data,
- AV_PKT_DATA_DISPLAYMATRIX);
-if (sd)
-displaymatrix = (int32_t *)sd->data;
 theta = get_rotation(displaymatrix);
 
 if (fabs(theta - 90) < 1.0) {
-- 
2.42.0

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

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


[FFmpeg-devel] [PATCH 02/10] fftools/ffmpeg_filter: compute input trim start/end in demuxer

2024-02-14 Thread Anton Khirnov
The computation is based on demuxer properties, so that is the more
appropriate place for it. Filter code just receives the desired
start time/duration.
---
 fftools/ffmpeg.h| 11 +++
 fftools/ffmpeg_demux.c  | 24 +++-
 fftools/ffmpeg_filter.c | 23 ++-
 3 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 33750e0bb3..cbc5413238 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -250,6 +250,11 @@ typedef struct OptionsContext {
 SpecifierOptList mux_stats_fmt;
 } OptionsContext;
 
+typedef struct InputFilterOptions {
+int64_t trim_start_us;
+int64_t trim_end_us;
+} InputFilterOptions;
+
 typedef struct InputFilter {
 struct FilterGraph *graph;
 uint8_t*name;
@@ -394,15 +399,12 @@ typedef struct InputFile {
 int64_t  ts_offset;
 /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
 int64_t  start_time;
-int64_t  recording_time;
 
 /* streams that ffmpeg is aware of;
  * there may be extra streams in ctx that are not mapped to an InputStream
  * if new streams appear dynamically during demuxing */
 InputStream**streams;
 int   nb_streams;
-
-int  accurate_seek;
 } InputFile;
 
 enum forced_keyframes_const {
@@ -790,7 +792,8 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch);
 void ifile_close(InputFile **f);
 
 int ist_output_add(InputStream *ist, OutputStream *ost);
-int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple);
+int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
+   InputFilterOptions *opts);
 
 /**
  * Find an unused input stream of given type.
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 3bf95e2c3f..abda4ad0d9 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -103,6 +103,9 @@ typedef struct Demuxer {
 int64_t ts_offset_discont;
 int64_t last_ts;
 
+int64_t recording_time;
+int accurate_seek;
+
 /* number of times input stream should be looped */
 int loop;
 int have_audio_dec;
@@ -450,13 +453,13 @@ static int input_packet_process(Demuxer *d, AVPacket 
*pkt, unsigned *send_flags)
 if (ret < 0)
 return ret;
 
-if (f->recording_time != INT64_MAX) {
+if (d->recording_time != INT64_MAX) {
 int64_t start_time = 0;
 if (copy_ts) {
 start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0;
 start_time += start_at_zero ? 0 : f->start_time_effective;
 }
-if (ds->dts >= f->recording_time + start_time)
+if (ds->dts >= d->recording_time + start_time)
 *send_flags |= DEMUX_SEND_STREAMCOPY_EOF;
 }
 
@@ -966,10 +969,12 @@ int ist_output_add(InputStream *ist, OutputStream *ost)
 return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream;
 }
 
-int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple)
+int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
+   InputFilterOptions *opts)
 {
 Demuxer  *d = demuxer_from_ifile(ist->file);
 DemuxStream *ds = ds_from_ist(ist);
+int64_t tsoffset = 0;
 int ret;
 
 ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
@@ -995,6 +1000,15 @@ int ist_filter_add(InputStream *ist, InputFilter 
*ifilter, int is_simple)
 ds->have_sub2video = 1;
 }
 
+if (copy_ts) {
+tsoffset = d->f.start_time == AV_NOPTS_VALUE ? 0 : d->f.start_time;
+if (!start_at_zero && d->f.ctx->start_time != AV_NOPTS_VALUE)
+tsoffset += d->f.ctx->start_time;
+}
+opts->trim_start_us = ((d->f.start_time == AV_NOPTS_VALUE) || 
!d->accurate_seek) ?
+  AV_NOPTS_VALUE : tsoffset;
+opts->trim_end_us   = d->recording_time;
+
 return ds->sch_idx_dec;
 }
 
@@ -1722,11 +1736,11 @@ int ifile_open(const OptionsContext *o, const char 
*filename, Scheduler *sch)
 }
 
 f->start_time = start_time;
-f->recording_time = recording_time;
+d->recording_time = recording_time;
 f->input_sync_ref = o->input_sync_ref;
 f->input_ts_offset = o->input_ts_offset;
 f->ts_offset  = o->input_ts_offset - (copy_ts ? (start_at_zero && 
ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
-f->accurate_seek = o->accurate_seek;
+d->accurate_seek   = o->accurate_seek;
 d->loop = o->loop;
 d->nb_streams_warn = ic->nb_streams;
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ed62e1d8ec..c411b882de 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -103,6 +103,8 @@ typedef struct FilterGraphThread {
 typedef struct InputFilterPriv {
 InputFilter ifilter;
 
+InputFilterOptions opts;
+
 int  index;
 
 AVFilterContext *filter;

[FFmpeg-devel] [PATCH 04/10] fftools/ffmpeg_filter: pass sub2video canvas size through InputFilterOptions

2024-02-14 Thread Anton Khirnov
Rather than read them directly from InputStream.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
 fftools/ffmpeg.h|  7 +++
 fftools/ffmpeg_demux.c  | 41 -
 fftools/ffmpeg_filter.c | 21 ++---
 3 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 2c1ad714b6..6db7b8a9c4 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -255,6 +255,9 @@ typedef struct InputFilterOptions {
 int64_t trim_end_us;
 
 uint8_t*name;
+
+int sub2video_width;
+int sub2video_height;
 } InputFilterOptions;
 
 typedef struct InputFilter {
@@ -366,10 +369,6 @@ typedef struct InputStream {
 
 int   fix_sub_duration;
 
-struct sub2video {
-int w, h;
-} sub2video;
-
 /* decoded data from this stream goes into all those filters
  * currently video and audio only */
 InputFilter **filters;
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 4cbad80e17..87ed8225c2 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -992,6 +992,26 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, 
int is_simple,
 return ret;
 
 if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+/* Compute the size of the canvas for the subtitles stream.
+   If the subtitles codecpar has set a size, use it. Otherwise use the
+   maximum dimensions of the video streams in the same file. */
+opts->sub2video_width  = ist->par->width;
+opts->sub2video_height = ist->par->height;
+if (!(opts->sub2video_width && opts->sub2video_height)) {
+for (int j = 0; j < d->f.nb_streams; j++) {
+AVCodecParameters *par1 = d->f.streams[j]->par;
+if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
+opts->sub2video_width  = FFMAX(opts->sub2video_width,  
par1->width);
+opts->sub2video_height = FFMAX(opts->sub2video_height, 
par1->height);
+}
+}
+}
+
+if (!(opts->sub2video_width && opts->sub2video_height)) {
+opts->sub2video_width  = FFMAX(opts->sub2video_width,  720);
+opts->sub2video_height = FFMAX(opts->sub2video_height, 576);
+}
+
 if (!d->pkt_heartbeat) {
 d->pkt_heartbeat = av_packet_alloc();
 if (!d->pkt_heartbeat)
@@ -1357,27 +1377,6 @@ static int ist_add(const OptionsContext *o, Demuxer *d, 
AVStream *st)
 return ret;
 }
 }
-
-/* Compute the size of the canvas for the subtitles stream.
-   If the subtitles codecpar has set a size, use it. Otherwise use the
-   maximum dimensions of the video streams in the same file. */
-ist->sub2video.w = par->width;
-ist->sub2video.h = par->height;
-if (!(ist->sub2video.w && ist->sub2video.h)) {
-for (int j = 0; j < ic->nb_streams; j++) {
-AVCodecParameters *par1 = ic->streams[j]->codecpar;
-if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
-ist->sub2video.w = FFMAX(ist->sub2video.w, par1->width);
-ist->sub2video.h = FFMAX(ist->sub2video.h, par1->height);
-}
-}
-}
-
-if (!(ist->sub2video.w && ist->sub2video.h)) {
-ist->sub2video.w = FFMAX(ist->sub2video.w, 720);
-ist->sub2video.h = FFMAX(ist->sub2video.h, 576);
-}
-
 break;
 }
 case AVMEDIA_TYPE_ATTACHMENT:
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 0f57035104..d182f3ab2e 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -689,6 +689,16 @@ static int ifilter_bind_ist(InputFilter *ifilter, 
InputStream *ist)
 ifp->sub2video.frame = av_frame_alloc();
 if (!ifp->sub2video.frame)
 return AVERROR(ENOMEM);
+
+ifp->width  = ifp->opts.sub2video_width;
+ifp->height = ifp->opts.sub2video_height;
+
+/* rectangles are AV_PIX_FMT_PAL8, but we have no guarantee that the
+   palettes for all rectangles are identical or compatible */
+ifp->format = AV_PIX_FMT_RGB32;
+
+av_log(fgp, AV_LOG_VERBOSE, "sub2video: using %dx%d canvas\n",
+   ifp->width, ifp->height);
 }
 
 return 0;
@@ -1829,17 +1839,6 @@ int ifilter_parameters_from_dec(InputFilter *ifilter, 
const AVCodecContext *dec)
 ret = av_channel_layout_copy(>fallback.ch_layout, 
>ch_layout);
 if (ret < 0)
 return ret;
-} else {
-// for subtitles (i.e. sub2video) we set the actual parameters,
-// rather than just fallback
-ifp->width  = ifp->ist->sub2video.w;
-ifp->height = ifp->ist->sub2video.h;
-
-/* rectangles are 

[FFmpeg-devel] [PATCH 03/10] fftools/ffmpeg_filter: accept a name from its upstream input

2024-02-14 Thread Anton Khirnov
Do not construct the name manually from input file/stream indices.

This is a step towards avoiding the assumption that filtergraph inputs
are always fed by demuxers.
---
 fftools/ffmpeg.h|  2 ++
 fftools/ffmpeg_demux.c  |  4 
 fftools/ffmpeg_filter.c | 21 -
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index cbc5413238..2c1ad714b6 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -253,6 +253,8 @@ typedef struct OptionsContext {
 typedef struct InputFilterOptions {
 int64_t trim_start_us;
 int64_t trim_end_us;
+
+uint8_t*name;
 } InputFilterOptions;
 
 typedef struct InputFilter {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index abda4ad0d9..4cbad80e17 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1009,6 +1009,10 @@ int ist_filter_add(InputStream *ist, InputFilter 
*ifilter, int is_simple,
   AV_NOPTS_VALUE : tsoffset;
 opts->trim_end_us   = d->recording_time;
 
+opts->name = av_strdup(ds->dec_name);
+if (!opts->name)
+return AVERROR(ENOMEM);
+
 return ds->sch_idx_dec;
 }
 
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index c411b882de..0f57035104 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -889,6 +889,7 @@ void fg_free(FilterGraph **pfg)
 
 av_buffer_unref(>hw_frames_ctx);
 av_freep(>linklabel);
+av_freep(>opts.name);
 av_freep(>name);
 av_freep(>inputs[j]);
 }
@@ -1475,7 +1476,6 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
 const AVPixFmtDescriptor *desc;
 InputStream *ist = ifp->ist;
-InputFile *f = ist->file;
 AVRational fr = ist->framerate;
 AVRational sar;
 AVBPrint args;
@@ -1506,8 +1506,8 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
  ifp->color_space, ifp->color_range);
 if (fr.num && fr.den)
 av_bprintf(, ":frame_rate=%d/%d", fr.num, fr.den);
-snprintf(name, sizeof(name), "graph %d input from stream %d:%d", fg->index,
- f->index, ist->index);
+snprintf(name, sizeof(name), "graph %d input from stream %s", fg->index,
+ ifp->opts.name);
 
 
 if ((ret = avfilter_graph_create_filter(>filter, buffer_filt, name,
@@ -1558,8 +1558,7 @@ static int configure_input_video_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 return ret;
 }
 
-snprintf(name, sizeof(name), "trim_in_%d_%d",
- f->index, ist->index);
+snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name);
 ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
   _filter, _idx, name);
 if (ret < 0)
@@ -1580,8 +1579,6 @@ static int configure_input_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
 AVFilterContext *last_filter;
 const AVFilter *abuffer_filt = avfilter_get_by_name("abuffer");
-InputStream *ist = ifp->ist;
-InputFile *f = ist->file;
 AVBPrint args;
 char name[255];
 int ret, pad_idx = 0;
@@ -1599,8 +1596,7 @@ static int configure_input_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 av_channel_layout_describe_bprint(>ch_layout, );
 } else
 av_bprintf(, ":channels=%d", ifp->ch_layout.nb_channels);
-snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
- f->index, ist->index);
+snprintf(name, sizeof(name), "graph_%d_in_%s", fg->index, ifp->opts.name);
 
 if ((ret = avfilter_graph_create_filter(>filter, abuffer_filt,
 name, args.str, NULL,
@@ -1608,8 +1604,7 @@ static int configure_input_audio_filter(FilterGraph *fg, 
AVFilterGraph *graph,
 return ret;
 last_filter = ifp->filter;
 
-snprintf(name, sizeof(name), "trim for input stream %d:%d",
- f->index, ist->index);
+snprintf(name, sizeof(name), "trim for input stream %s", ifp->opts.name);
 ret = insert_trim(ifp->opts.trim_start_us, ifp->opts.trim_end_us,
   _filter, _idx, name);
 if (ret < 0)
@@ -2566,8 +2561,8 @@ static int send_eof(FilterGraphThread *fgt, InputFilter 
*ifilter,
 
 if (ifp->format < 0) {
 av_log(NULL, AV_LOG_ERROR,
-   "Cannot determine format of input stream %d:%d after EOF\n",
-   ifp->ist->file->index, ifp->ist->index);
+   "Cannot determine format of input %s after EOF\n",
+   ifp->opts.name);
 return AVERROR_INVALIDDATA;
 }
 }
-- 
2.42.0

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

To unsubscribe, 

Re: [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils

2024-02-14 Thread Michael Niedermayer
On Tue, Feb 13, 2024 at 11:50:09PM +0100, Matthieu Bouron wrote:
> This will allow to use the jni utils in libavformat. This will be mostly 
> useful
> to add Android content-uri support.
> 
> This deprecates avcodec/jni.h functions in favor of the ones from 
> avutil/jni.h.
> ---
>  doc/APIchanges |   6 +
>  libavcodec/Makefile|   3 +-
>  libavcodec/jni.c   |  48 +
>  libavcodec/jni.h   |   8 +
>  libavcodec/mediacodec.c|   6 +-
>  libavcodec/mediacodec_surface.c|   6 +-
>  libavcodec/mediacodec_wrapper.c| 200 ++---
>  libavcodec/mediacodecdec.c |   3 +-
>  libavutil/Makefile |   4 +
>  libavutil/jni.c|  78 
>  libavutil/jni.h|  46 +
>  libavcodec/ffjni.c => libavutil/jniutils.c |  36 ++--
>  libavcodec/ffjni.h => libavutil/jniutils.h |  26 ++-
>  13 files changed, 283 insertions(+), 187 deletions(-)
>  create mode 100644 libavutil/jni.c
>  create mode 100644 libavutil/jni.h
>  rename libavcodec/ffjni.c => libavutil/jniutils.c (88%)
>  rename libavcodec/ffjni.h => libavutil/jniutils.h (84%)

this breaks build

 make
CC  libavutil/jni.o
libavutil/jni.c:68:5: error: no previous prototype for ‘av_jni_set_java_vm’ 
[-Werror=missing-prototypes]
 int av_jni_set_java_vm(void *vm, void *log_ctx)
 ^~
libavutil/jni.c:73:7: error: no previous prototype for ‘av_jni_get_java_vm’ 
[-Werror=missing-prototypes]
 void *av_jni_get_java_vm(void *log_ctx)
   ^~
cc1: some warnings being treated as errors
ffbuild/common.mak:81: recipe for target 'libavutil/jni.o' failed
make: *** [libavutil/jni.o] Error 1


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

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


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

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


[FFmpeg-devel] [PATCH 8/8] avfilter/avfilter: Move frame_pool to FilterLinkInternal

2024-02-14 Thread Andreas Rheinhardt
Avoids ugly casts when uninitializing.
(One could actually avoid allocating this separately if one
were willing to expose FFFramePool to those files including
link_internal.h.)

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/audio.c | 22 --
 libavfilter/avfilter.c  |  2 +-
 libavfilter/avfilter.h  |  5 -
 libavfilter/link_internal.h |  2 ++
 libavfilter/video.c | 22 --
 5 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index 35270c14d2..abcbaf7304 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -28,6 +28,7 @@
 #include "avfilter.h"
 #include "framepool.h"
 #include "internal.h"
+#include "link_internal.h"
 
 const AVFilterPad ff_audio_default_filterpad[1] = {
 {
@@ -44,6 +45,7 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int 
nb_samples)
 AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
 {
 AVFrame *frame = NULL;
+FilterLinkInternal *const li = ff_link_internal(link);
 int channels = link->ch_layout.nb_channels;
 int align = av_cpu_max_align();
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -54,10 +56,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 
-if (!link->frame_pool) {
-link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
-nb_samples, link->format, 
align);
-if (!link->frame_pool)
+if (!li->frame_pool) {
+li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
+  nb_samples, link->format, 
align);
+if (!li->frame_pool)
 return NULL;
 } else {
 int pool_channels = 0;
@@ -65,7 +67,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 int pool_align = 0;
 enum AVSampleFormat pool_format = AV_SAMPLE_FMT_NONE;
 
-if (ff_frame_pool_get_audio_config(link->frame_pool,
+if (ff_frame_pool_get_audio_config(li->frame_pool,
_channels, _nb_samples,
_format, _align) < 0) {
 return NULL;
@@ -74,15 +76,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (pool_channels != channels || pool_nb_samples < nb_samples ||
 pool_format != link->format || pool_align != align) {
 
-ff_frame_pool_uninit((FFFramePool **)>frame_pool);
-link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, 
channels,
-nb_samples, 
link->format, align);
-if (!link->frame_pool)
+ff_frame_pool_uninit(>frame_pool);
+li->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, 
channels,
+  nb_samples, 
link->format, align);
+if (!li->frame_pool)
 return NULL;
 }
 }
 
-frame = ff_frame_pool_get(link->frame_pool);
+frame = ff_frame_pool_get(li->frame_pool);
 if (!frame)
 return NULL;
 
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 52ef5ca9a4..44185ff3e6 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -202,7 +202,7 @@ void avfilter_link_free(AVFilterLink **link)
 li = ff_link_internal(*link);
 
 ff_framequeue_free(>fifo);
-ff_frame_pool_uninit((FFFramePool**)&(*link)->frame_pool);
+ff_frame_pool_uninit(>frame_pool);
 av_channel_layout_uninit(&(*link)->ch_layout);
 
 av_freep(link);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 9252713ae2..5eff35b836 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -666,11 +666,6 @@ struct AVFilterLink {
  */
 int64_t sample_count_in, sample_count_out;
 
-/**
- * A pointer to a FFFramePool struct.
- */
-void *frame_pool;
-
 /**
  * True if a frame is currently wanted on the output of this filter.
  * Set when ff_request_frame() is called by the output,
diff --git a/libavfilter/link_internal.h b/libavfilter/link_internal.h
index 57efd44a45..c01c15109e 100644
--- a/libavfilter/link_internal.h
+++ b/libavfilter/link_internal.h
@@ -29,6 +29,8 @@
 typedef struct FilterLinkInternal {
 AVFilterLink l;
 
+struct FFFramePool *frame_pool;
+
 /**
  * Queue of frames waiting to be filtered.
  */
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 243762c8fd..22412244ad 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -31,6 +31,7 @@
 #include "avfilter.h"
 #include "framepool.h"
 #include "internal.h"
+#include "link_internal.h"
 #include "video.h"
 
 const AVFilterPad ff_video_default_filterpad[1] = {
@@ -47,6 +48,7 @@ AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, 
int h)
 
 AVFrame *ff_default_get_video_buffer2(AVFilterLink *link, int w, int h, int 
align)
 {
+

[FFmpeg-devel] [PATCH 7/8] avfilter/avfilter: Move age_index to FilterLinkInternal

2024-02-14 Thread Andreas Rheinhardt
Also make FFFilterGraph.sink_links a FilterLinkInternal**
because sink_links is used to access FilterLinkInternal
fields.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.c  | 21 +++-
 libavfilter/avfilter.h  |  5 ---
 libavfilter/avfilter_internal.h |  5 +--
 libavfilter/avfiltergraph.c | 61 +
 libavfilter/link_internal.h |  5 +++
 5 files changed, 52 insertions(+), 45 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index a3f8c403c3..52ef5ca9a4 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -208,15 +208,17 @@ void avfilter_link_free(AVFilterLink **link)
 av_freep(link);
 }
 
-static void update_link_current_pts(AVFilterLink *link, int64_t pts)
+static void update_link_current_pts(FilterLinkInternal *li, int64_t pts)
 {
+AVFilterLink *const link = >l;
+
 if (pts == AV_NOPTS_VALUE)
 return;
 link->current_pts = pts;
 link->current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
 /* TODO use duration */
-if (link->graph && link->age_index >= 0)
-ff_avfilter_graph_update_heap(link->graph, link);
+if (link->graph && li->age_index >= 0)
+ff_avfilter_graph_update_heap(link->graph, li);
 }
 
 void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
@@ -266,7 +268,7 @@ static void link_set_out_status(AVFilterLink *link, int 
status, int64_t pts)
 av_assert0(!li->status_out);
 li->status_out = status;
 if (pts != AV_NOPTS_VALUE)
-update_link_current_pts(link, pts);
+update_link_current_pts(li, pts);
 filter_unblock(link->dst);
 ff_filter_set_ready(link->src, 200);
 }
@@ -1393,7 +1395,7 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int 
*rstatus, int64_t *rpts
 if (!li->status_in)
 return *rstatus = 0;
 *rstatus = li->status_out = li->status_in;
-update_link_current_pts(link, li->status_in_pts);
+update_link_current_pts(li, li->status_in_pts);
 *rpts = link->current_pts;
 return 1;
 }
@@ -1424,9 +1426,10 @@ int ff_inlink_check_available_samples(AVFilterLink 
*link, unsigned min)
 return samples >= min || (li->status_in && samples);
 }
 
-static void consume_update(AVFilterLink *link, const AVFrame *frame)
+static void consume_update(FilterLinkInternal *li, const AVFrame *frame)
 {
-update_link_current_pts(link, frame->pts);
+AVFilterLink *const link = >l;
+update_link_current_pts(li, frame->pts);
 ff_inlink_process_commands(link, frame);
 link->dst->is_disabled = !ff_inlink_evaluate_timeline_at_frame(link, 
frame);
 link->frame_count_out++;
@@ -1448,7 +1451,7 @@ int ff_inlink_consume_frame(AVFilterLink *link, AVFrame 
**rframe)
 }
 
 frame = ff_framequeue_take(>fifo);
-consume_update(link, frame);
+consume_update(li, frame);
 *rframe = frame;
 return 1;
 }
@@ -1469,7 +1472,7 @@ int ff_inlink_consume_samples(AVFilterLink *link, 
unsigned min, unsigned max,
 ret = take_samples(li, min, max, );
 if (ret < 0)
 return ret;
-consume_update(link, frame);
+consume_update(li, frame);
 *rframe = frame;
 return 1;
 }
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 5c6e34e8fc..9252713ae2 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -628,11 +628,6 @@ struct AVFilterLink {
  */
 int64_t current_pts_us;
 
-/**
- * Index in the age array.
- */
-int age_index;
-
 /**
  * Frame rate of the stream on the link, or 1/0 if unknown or variable;
  * if left to 0/0, will be automatically copied from the first input
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 72712608e7..5ad44ca866 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -42,7 +42,7 @@ typedef struct FFFilterGraph {
  */
 AVFilterGraph p;
 
-AVFilterLink **sink_links;
+struct FilterLinkInternal **sink_links;
 int sink_links_count;
 
 unsigned disable_auto_convert;
@@ -60,7 +60,8 @@ static inline FFFilterGraph *fffiltergraph(AVFilterGraph 
*graph)
 /**
  * Update the position of a link in the age heap.
  */
-void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link);
+void ff_avfilter_graph_update_heap(AVFilterGraph *graph,
+   struct FilterLinkInternal *li);
 
 /**
  * Allocate a new filter context and return it.
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 5278cf2010..9c91953cc9 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -1286,17 +1286,17 @@ static int graph_config_pointers(AVFilterGraph *graph, 
void *log_ctx)
 unsigned i, j;
 int sink_links_count = 0, n = 0;
 AVFilterContext *f;
-AVFilterLink **sinks;
+FilterLinkInternal **sinks;
 
 for (i = 0; i < graph->nb_filters; i++) {
 f = 

[FFmpeg-devel] [PATCH 6/8] avfilter/avfilter: Move init_state to FilterLinkInternal

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.c  | 7 ---
 libavfilter/avfilter.h  | 7 ---
 libavfilter/link_internal.h | 7 +++
 3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 796ec29afd..a3f8c403c3 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -323,6 +323,7 @@ int avfilter_config_links(AVFilterContext *filter)
 for (i = 0; i < filter->nb_inputs; i ++) {
 AVFilterLink *link = filter->inputs[i];
 AVFilterLink *inlink;
+FilterLinkInternal *li = ff_link_internal(link);
 
 if (!link) continue;
 if (!link->src || !link->dst) {
@@ -335,14 +336,14 @@ int avfilter_config_links(AVFilterContext *filter)
 link->current_pts =
 link->current_pts_us = AV_NOPTS_VALUE;
 
-switch (link->init_state) {
+switch (li->init_state) {
 case AVLINK_INIT:
 continue;
 case AVLINK_STARTINIT:
 av_log(filter, AV_LOG_INFO, "circular filter chain detected\n");
 return 0;
 case AVLINK_UNINIT:
-link->init_state = AVLINK_STARTINIT;
+li->init_state = AVLINK_STARTINIT;
 
 if ((ret = avfilter_config_links(link->src)) < 0)
 return ret;
@@ -413,7 +414,7 @@ int avfilter_config_links(AVFilterContext *filter)
 return ret;
 }
 
-link->init_state = AVLINK_INIT;
+li->init_state = AVLINK_INIT;
 }
 }
 
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 1d2909e28d..5c6e34e8fc 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -611,13 +611,6 @@ struct AVFilterLink {
  */
 AVFilterFormatsConfig outcfg;
 
-/** stage of the initialization of the link properties (dimensions, etc) */
-enum {
-AVLINK_UNINIT = 0,  ///< not started
-AVLINK_STARTINIT,   ///< started, but incomplete
-AVLINK_INIT ///< complete
-} init_state;
-
 /**
  * Graph the filter belongs to.
  */
diff --git a/libavfilter/link_internal.h b/libavfilter/link_internal.h
index b5a8ac89ec..030eb24765 100644
--- a/libavfilter/link_internal.h
+++ b/libavfilter/link_internal.h
@@ -59,6 +59,13 @@ typedef struct FilterLinkInternal {
  * corresponding code.
  */
 int status_out;
+
+/** stage of the initialization of the link properties (dimensions, etc) */
+enum {
+AVLINK_UNINIT = 0,  ///< not started
+AVLINK_STARTINIT,   ///< started, but incomplete
+AVLINK_INIT ///< complete
+} init_state;
 } FilterLinkInternal;
 
 static inline FilterLinkInternal *ff_link_internal(AVFilterLink *link)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 5/8] avfilter/avfilter: Move AVFilterGraph private fields to FFFilterGraph

2024-02-14 Thread Andreas Rheinhardt
(These fields were in AVFilterGraph although AVFilterGraphInternal
existed for years.)

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.h  | 12 
 libavfilter/avfilter_internal.h |  6 ++
 libavfilter/avfiltergraph.c | 32 +---
 3 files changed, 23 insertions(+), 27 deletions(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index b5346f40ab..1d2909e28d 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -899,18 +899,6 @@ typedef struct AVFilterGraph {
 avfilter_execute_func *execute;
 
 char *aresample_swr_opts; ///< swr options to use for the auto-inserted 
aresample filters, Access ONLY through AVOptions
-
-/**
- * Private fields
- *
- * The following fields are for internal use only.
- * Their type, offset, number and semantic can change without notice.
- */
-
-AVFilterLink **sink_links;
-int sink_links_count;
-
-unsigned disable_auto_convert;
 } AVFilterGraph;
 
 /**
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 9ddb82bf26..72712608e7 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -41,6 +41,12 @@ typedef struct FFFilterGraph {
  * The public AVFilterGraph. See avfilter.h for it.
  */
 AVFilterGraph p;
+
+AVFilterLink **sink_links;
+int sink_links_count;
+
+unsigned disable_auto_convert;
+
 void *thread;
 avfilter_execute_func *thread_execute;
 FFFrameQueueGlobal frame_queues;
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 1e7874adc6..5278cf2010 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -127,7 +127,7 @@ void avfilter_graph_free(AVFilterGraph **graphp)
 
 ff_graph_thread_free(graphi);
 
-av_freep(>sink_links);
+av_freep(>sink_links);
 
 av_opt_free(graph);
 
@@ -159,7 +159,7 @@ fail:
 
 void avfilter_graph_set_auto_convert(AVFilterGraph *graph, unsigned flags)
 {
-graph->disable_auto_convert = flags;
+fffiltergraph(graph)->disable_auto_convert = flags;
 }
 
 AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph,
@@ -471,7 +471,7 @@ static int query_formats(AVFilterGraph *graph, void 
*log_ctx)
 char inst_name[30];
 const char *opts;
 
-if (graph->disable_auto_convert) {
+if (fffiltergraph(graph)->disable_auto_convert) {
 av_log(log_ctx, AV_LOG_ERROR,
"The filters '%s' and '%s' do not have a common 
format "
"and automatic conversion is disabled.\n",
@@ -1317,8 +1317,8 @@ static int graph_config_pointers(AVFilterGraph *graph, 
void *log_ctx)
 }
 }
 av_assert0(n == sink_links_count);
-graph->sink_links   = sinks;
-graph->sink_links_count = sink_links_count;
+fffiltergraph(graph)->sink_links   = sinks;
+fffiltergraph(graph)->sink_links_count = sink_links_count;
 return 0;
 }
 
@@ -1401,7 +1401,7 @@ int avfilter_graph_queue_command(AVFilterGraph *graph, 
const char *target, const
 return 0;
 }
 
-static void heap_bubble_up(AVFilterGraph *graph,
+static void heap_bubble_up(FFFilterGraph *graph,
AVFilterLink *link, int index)
 {
 AVFilterLink **links = graph->sink_links;
@@ -1420,7 +1420,7 @@ static void heap_bubble_up(AVFilterGraph *graph,
 link->age_index = index;
 }
 
-static void heap_bubble_down(AVFilterGraph *graph,
+static void heap_bubble_down(FFFilterGraph *graph,
  AVFilterLink *link, int index)
 {
 AVFilterLink **links = graph->sink_links;
@@ -1446,18 +1446,20 @@ static void heap_bubble_down(AVFilterGraph *graph,
 
 void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link)
 {
-heap_bubble_up  (graph, link, link->age_index);
-heap_bubble_down(graph, link, link->age_index);
+FFFilterGraph *graphi = fffiltergraph(graph);
+heap_bubble_up  (graphi, link, link->age_index);
+heap_bubble_down(graphi, link, link->age_index);
 }
 
 int avfilter_graph_request_oldest(AVFilterGraph *graph)
 {
-AVFilterLink *oldest = graph->sink_links[0];
+FFFilterGraph *graphi = fffiltergraph(graph);
+AVFilterLink *oldest = graphi->sink_links[0];
 int64_t frame_count;
 int r;
 
-while (graph->sink_links_count) {
-oldest = graph->sink_links[0];
+while (graphi->sink_links_count) {
+oldest = graphi->sink_links[0];
 if (oldest->dst->filter->activate) {
 r = av_buffersink_get_frame_flags(oldest->dst, NULL,
   AV_BUFFERSINK_FLAG_PEEK);
@@ -1472,12 +1474,12 @@ int avfilter_graph_request_oldest(AVFilterGraph *graph)
oldest->dst->name,
oldest->dstpad->name);
 /* EOF: remove the link from the heap */
-if (oldest->age_index < 

[FFmpeg-devel] [PATCH 4/8] avfilter/avfiltergraph: Avoid allocation for AVFilterGraphInternal

2024-02-14 Thread Andreas Rheinhardt
To do this, allocate AVFilterGraphInternal jointly with AVFilterGraph
and rename it to FFFilterGraph in the process (similarly to
AVStream/FFStream).
The AVFilterGraphInternal* will be removed on the next major version
bump.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.c  |  6 +++---
 libavfilter/avfilter_internal.h | 17 +
 libavfilter/avfiltergraph.c | 32 +++-
 libavfilter/pthread.c   | 23 ---
 4 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 5dcb548e90..796ec29afd 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -188,7 +188,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
 link->format  = -1;
 link->colorspace = AVCOL_SPC_UNSPECIFIED;
-ff_framequeue_init(>fifo, >graph->internal->frame_queues);
+ff_framequeue_init(>fifo, (src->graph)->frame_queues);
 
 return 0;
 }
@@ -905,9 +905,9 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 
 if (ctx->filter->flags & AVFILTER_FLAG_SLICE_THREADS &&
 ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE &&
-ctx->graph->internal->thread_execute) {
+fffiltergraph(ctx->graph)->thread_execute) {
 ctx->thread_type   = AVFILTER_THREAD_SLICE;
-ctxi->execute= ctx->graph->internal->thread_execute;
+ctxi->execute= fffiltergraph(ctx->graph)->thread_execute;
 } else {
 ctx->thread_type = 0;
 }
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
index 3dd51fb993..9ddb82bf26 100644
--- a/libavfilter/avfilter_internal.h
+++ b/libavfilter/avfilter_internal.h
@@ -36,11 +36,20 @@ typedef struct AVFilterCommand {
 struct AVFilterCommand *next;
 } AVFilterCommand;
 
-struct AVFilterGraphInternal {
+typedef struct FFFilterGraph {
+/**
+ * The public AVFilterGraph. See avfilter.h for it.
+ */
+AVFilterGraph p;
 void *thread;
 avfilter_execute_func *thread_execute;
 FFFrameQueueGlobal frame_queues;
-};
+} FFFilterGraph;
+
+static inline FFFilterGraph *fffiltergraph(AVFilterGraph *graph)
+{
+return (FFFilterGraph*)graph;
+}
 
 /**
  * Update the position of a link in the age heap.
@@ -77,8 +86,8 @@ int ff_filter_activate(AVFilterContext *filter);
 int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
 AVDictionary **options, const char *args);
 
-int ff_graph_thread_init(AVFilterGraph *graph);
+int ff_graph_thread_init(FFFilterGraph *graph);
 
-void ff_graph_thread_free(AVFilterGraph *graph);
+void ff_graph_thread_free(FFFilterGraph *graph);
 
 #endif /* AVFILTER_AVFILTER_INTERNAL_H */
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index a9befb954f..1e7874adc6 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -68,33 +68,30 @@ static const AVClass filtergraph_class = {
 };
 
 #if !HAVE_THREADS
-void ff_graph_thread_free(AVFilterGraph *graph)
+void ff_graph_thread_free(FFFilterGraph *graph)
 {
 }
 
-int ff_graph_thread_init(AVFilterGraph *graph)
+int ff_graph_thread_init(FFFilterGraph *graph)
 {
-graph->thread_type = 0;
-graph->nb_threads  = 1;
+graph->p.thread_type = 0;
+graph->p.nb_threads  = 1;
 return 0;
 }
 #endif
 
 AVFilterGraph *avfilter_graph_alloc(void)
 {
-AVFilterGraph *ret = av_mallocz(sizeof(*ret));
-if (!ret)
-return NULL;
+FFFilterGraph *graph = av_mallocz(sizeof(*graph));
+AVFilterGraph *ret;
 
-ret->internal = av_mallocz(sizeof(*ret->internal));
-if (!ret->internal) {
-av_freep();
+if (!graph)
 return NULL;
-}
 
+ret = >p;
 ret->av_class = _class;
 av_opt_set_defaults(ret);
-ff_framequeue_global_init(>internal->frame_queues);
+ff_framequeue_global_init(>frame_queues);
 
 return ret;
 }
@@ -120,6 +117,7 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, 
AVFilterContext *filter
 void avfilter_graph_free(AVFilterGraph **graphp)
 {
 AVFilterGraph *graph = *graphp;
+FFFilterGraph *graphi = fffiltergraph(graph);
 
 if (!graph)
 return;
@@ -127,14 +125,13 @@ void avfilter_graph_free(AVFilterGraph **graphp)
 while (graph->nb_filters)
 avfilter_free(graph->filters[0]);
 
-ff_graph_thread_free(graph);
+ff_graph_thread_free(graphi);
 
 av_freep(>sink_links);
 
 av_opt_free(graph);
 
 av_freep(>filters);
-av_freep(>internal);
 av_freep(graphp);
 }
 
@@ -170,12 +167,13 @@ AVFilterContext 
*avfilter_graph_alloc_filter(AVFilterGraph *graph,
  const char *name)
 {
 AVFilterContext **filters, *s;
+FFFilterGraph *graphi = fffiltergraph(graph);
 
-if (graph->thread_type && !graph->internal->thread_execute) {
+if 

[FFmpeg-devel] [PATCH 3/8] avfilter/avfiltergraph: Avoid indirection when freeing filtergraph

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfiltergraph.c | 22 --
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index df22de03a0..a9befb954f 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -117,23 +117,25 @@ void ff_filter_graph_remove_filter(AVFilterGraph *graph, 
AVFilterContext *filter
 }
 }
 
-void avfilter_graph_free(AVFilterGraph **graph)
+void avfilter_graph_free(AVFilterGraph **graphp)
 {
-if (!*graph)
+AVFilterGraph *graph = *graphp;
+
+if (!graph)
 return;
 
-while ((*graph)->nb_filters)
-avfilter_free((*graph)->filters[0]);
+while (graph->nb_filters)
+avfilter_free(graph->filters[0]);
 
-ff_graph_thread_free(*graph);
+ff_graph_thread_free(graph);
 
-av_freep(&(*graph)->sink_links);
+av_freep(>sink_links);
 
-av_opt_free(*graph);
+av_opt_free(graph);
 
-av_freep(&(*graph)->filters);
-av_freep(&(*graph)->internal);
-av_freep(graph);
+av_freep(>filters);
+av_freep(>internal);
+av_freep(graphp);
 }
 
 int avfilter_graph_create_filter(AVFilterContext **filt_ctx, const AVFilter 
*filt,
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/8] avfilter: Add a header for internal generic-layer APIs

2024-02-14 Thread Andreas Rheinhardt
This commit moves the generic-layer stuff (that is not used
by filters) to a new header of its own, similarly to
5e7b5b0090bdf68e0897fe55ee657fdccc0cbca2 for libavcodec.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.c  |  1 +
 libavfilter/avfilter_internal.h | 84 +
 libavfilter/avfiltergraph.c |  2 +-
 libavfilter/graphparser.c   |  1 +
 libavfilter/internal.h  | 50 
 libavfilter/pthread.c   |  3 +-
 libavfilter/thread.h| 28 ---
 7 files changed, 88 insertions(+), 81 deletions(-)
 create mode 100644 libavfilter/avfilter_internal.h
 delete mode 100644 libavfilter/thread.h

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 2d935cf576..5dcb548e90 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -36,6 +36,7 @@
 
 #include "audio.h"
 #include "avfilter.h"
+#include "avfilter_internal.h"
 #include "filters.h"
 #include "formats.h"
 #include "framequeue.h"
diff --git a/libavfilter/avfilter_internal.h b/libavfilter/avfilter_internal.h
new file mode 100644
index 00..3dd51fb993
--- /dev/null
+++ b/libavfilter/avfilter_internal.h
@@ -0,0 +1,84 @@
+/*
+ * 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
+ */
+
+/*
+ * APIs internal to the generic filter(graph) layer.
+ *
+ * MUST NOT be included by individual filters.
+ */
+
+#ifndef AVFILTER_AVFILTER_INTERNAL_H
+#define AVFILTER_AVFILTER_INTERNAL_H
+
+#include "avfilter.h"
+#include "framequeue.h"
+
+typedef struct AVFilterCommand {
+double time;///< time expressed in seconds
+char *command;  ///< command
+char *arg;  ///< optional argument for the command
+int flags;
+struct AVFilterCommand *next;
+} AVFilterCommand;
+
+struct AVFilterGraphInternal {
+void *thread;
+avfilter_execute_func *thread_execute;
+FFFrameQueueGlobal frame_queues;
+};
+
+/**
+ * Update the position of a link in the age heap.
+ */
+void ff_avfilter_graph_update_heap(AVFilterGraph *graph, AVFilterLink *link);
+
+/**
+ * Allocate a new filter context and return it.
+ *
+ * @param filter what filter to create an instance of
+ * @param inst_name name to give to the new filter context
+ *
+ * @return newly created filter context or NULL on failure
+ */
+AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char 
*inst_name);
+
+/**
+ * Remove a filter from a graph;
+ */
+void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext 
*filter);
+
+int ff_filter_activate(AVFilterContext *filter);
+
+/**
+ * Parse filter options into a dictionary.
+ *
+ * @param logctx context for logging
+ * @param priv_class a filter's private class for shorthand options or NULL
+ * @param options dictionary to store parsed options in
+ * @param args options string to parse
+ *
+ * @return a non-negative number on success, a negative error code on failure
+ */
+int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
+AVDictionary **options, const char *args);
+
+int ff_graph_thread_init(AVFilterGraph *graph);
+
+void ff_graph_thread_free(AVFilterGraph *graph);
+
+#endif /* AVFILTER_AVFILTER_INTERNAL_H */
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index ea0d7713e3..df22de03a0 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -34,12 +34,12 @@
 
 
 #include "avfilter.h"
+#include "avfilter_internal.h"
 #include "buffersink.h"
 #include "formats.h"
 #include "framequeue.h"
 #include "internal.h"
 #include "link_internal.h"
-#include "thread.h"
 
 #define OFFSET(x) offsetof(AVFilterGraph, x)
 #define F AV_OPT_FLAG_FILTERING_PARAM
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 229e647c0a..5d6dcdb9d3 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -29,6 +29,7 @@
 #include "libavutil/opt.h"
 
 #include "avfilter.h"
+#include "avfilter_internal.h"
 #include "internal.h"
 
 #define WHITESPACES " \n\t\r"
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index 3d46923cad..0e3f68d1f4 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -26,20 +26,6 @@
 
 #include "libavutil/internal.h"
 #include 

[FFmpeg-devel] [PATCH 1/8] avfilter/avfilter: Avoid allocation for AVFilterInternal

2024-02-14 Thread Andreas Rheinhardt
To do this, allocate AVFilterInternal jointly with AVFilterContext
and rename it to FFFilterContext in the process (similarly to
AVStream/FFStream).
The AVFilterInternal* will be removed from AVFilterContext
on the next major bump.

Signed-off-by: Andreas Rheinhardt 
---
Several of these patches are from the bump patchset; I have just
removed the removal of the internal-pointers, so that this could
be applied at any time.

 libavfilter/avfilter.c| 22 ++
 libavfilter/graphparser.c |  2 +-
 libavfilter/internal.h| 16 +---
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 9fe249f3f9..2d935cf576 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -159,7 +159,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
 src->outputs[srcpad]  || dst->inputs[dstpad])
 return AVERROR(EINVAL);
 
-if (!src->internal->initialized || !dst->internal->initialized) {
+if (!fffilterctx(src)->initialized || !fffilterctx(dst)->initialized) {
 av_log(src, AV_LOG_ERROR, "Filters must be initialized before 
linking.\n");
 return AVERROR(EINVAL);
 }
@@ -668,15 +668,17 @@ static int default_execute(AVFilterContext *ctx, 
avfilter_action_func *func, voi
 
 AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name)
 {
+FFFilterContext *ctx;
 AVFilterContext *ret;
 int preinited = 0;
 
 if (!filter)
 return NULL;
 
-ret = av_mallocz(sizeof(AVFilterContext));
-if (!ret)
+ctx = av_mallocz(sizeof(*ctx));
+if (!ctx)
 return NULL;
+ret = >p;
 
 ret->av_class = _class;
 ret->filter   = filter;
@@ -698,10 +700,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, 
const char *inst_name)
 av_opt_set_defaults(ret->priv);
 }
 
-ret->internal = av_mallocz(sizeof(*ret->internal));
-if (!ret->internal)
-goto err;
-ret->internal->execute = default_execute;
+ctx->execute = default_execute;
 
 ret->nb_inputs  = filter->nb_inputs;
 if (ret->nb_inputs ) {
@@ -735,7 +734,6 @@ err:
 av_freep(>output_pads);
 ret->nb_outputs = 0;
 av_freep(>priv);
-av_freep(>internal);
 av_free(ret);
 return NULL;
 }
@@ -807,7 +805,6 @@ void avfilter_free(AVFilterContext *filter)
 av_expr_free(filter->enable);
 filter->enable = NULL;
 av_freep(>var_values);
-av_freep(>internal);
 av_free(filter);
 }
 
@@ -891,9 +888,10 @@ int ff_filter_process_command(AVFilterContext *ctx, const 
char *cmd,
 
 int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
 {
+FFFilterContext *ctxi = fffilterctx(ctx);
 int ret = 0;
 
-if (ctx->internal->initialized) {
+if (ctxi->initialized) {
 av_log(ctx, AV_LOG_ERROR, "Filter already initialized\n");
 return AVERROR(EINVAL);
 }
@@ -908,7 +906,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE &&
 ctx->graph->internal->thread_execute) {
 ctx->thread_type   = AVFILTER_THREAD_SLICE;
-ctx->internal->execute = ctx->graph->internal->thread_execute;
+ctxi->execute= ctx->graph->internal->thread_execute;
 } else {
 ctx->thread_type = 0;
 }
@@ -924,7 +922,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary 
**options)
 return ret;
 }
 
-ctx->internal->initialized = 1;
+ctxi->initialized = 1;
 
 return 0;
 }
diff --git a/libavfilter/graphparser.c b/libavfilter/graphparser.c
index 96ef6b15bf..229e647c0a 100644
--- a/libavfilter/graphparser.c
+++ b/libavfilter/graphparser.c
@@ -626,7 +626,7 @@ int avfilter_graph_segment_init(AVFilterGraphSegment *seg, 
int flags)
 
 if (p->filter_name)
 return fail_creation_pending(seg, p->filter_name, __func__);
-if (!p->filter || p->filter->internal->initialized)
+if (!p->filter || fffilterctx(p->filter)->initialized)
 continue;
 
 ret = avfilter_init_dict(p->filter, NULL);
diff --git a/libavfilter/internal.h b/libavfilter/internal.h
index a6cdf9994c..3d46923cad 100644
--- a/libavfilter/internal.h
+++ b/libavfilter/internal.h
@@ -133,18 +133,28 @@ struct AVFilterGraphInternal {
 FFFrameQueueGlobal frame_queues;
 };
 
-struct AVFilterInternal {
+typedef struct FFFilterContext {
+/**
+ * The public AVFilterContext. See avfilter.h for it.
+ */
+AVFilterContext p;
+
 avfilter_execute_func *execute;
 
 // 1 when avfilter_init_*() was successfully called on this filter
 // 0 otherwise
 int initialized;
-};
+} FFFilterContext;
+
+static inline FFFilterContext *fffilterctx(AVFilterContext *ctx)
+{
+return (FFFilterContext*)ctx;
+}
 
 static av_always_inline int ff_filter_execute(AVFilterContext *ctx, 
avfilter_action_func 

Re: [FFmpeg-devel] [PATCH 1/9] libavutil: add hwcontext_amf.

2024-02-14 Thread Dmitrii Ovchinnikov
>>AVAMFDeviceContextInternal *internal. Can't say if this is needed here
>>at all or not.
I have separated AVAMFDeviceContextInternal into a separate structure,
since it is also used in the decoder and encoder, even when
hwaccel amf is not used

>>These should probably take a AVAMFDeviceContext pointer.
they are also used from the decoder and encoder for initialization,
even when hwaccel amf is not used
I did this to avoid massive code duplication.

If you have any thoughts on how to improve this, it would be great.
For the rest of the comments, everything is clear,
I will correct and send an updated version.


-- 
Sincerely, Ovchinnikov D.A.
___
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 8/9] avfilter/scale_amf: Add AMF HW scaler & color converter

2024-02-14 Thread Dennis Mungai
On Wed, 14 Feb 2024, 18:28 Evgeny Pavlov,  wrote:

> On Wed, Feb 14, 2024 at 4:08 PM Timo Rothenpieler 
> wrote:
>
> > On 14/02/2024 02:55, Dmitrii Ovchinnikov wrote:
> > > From: Evgeny Pavlov 
> > >
> > > This commit adds two AMF filters: scale_amf & scale_amf_hq.
> > > Both filters are using AMF hardware acceleration.
> > > scale_amf supports simple scaling algorithms & color conversion.
> > > scale_amf_hq supports advanced scaling algorithms & might be used
> > > for upscaling only.
> >
> > Haven't looked at the patch yet, but can't this be one filter, and it
> > picks the best possible method depending on options/inputs/whatever?
> > ___
> > 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".
> >
>
> AMF has 2 separate components for color conversion + simple scaling
> (VideoConverter)  and for advanced scaling (HQScaler).
> We've got a recommendation from the AMD AMF team to implement these
> components as separate ffmpeg filters.
>


Still, this should be a single VIdeo Post-Processing (VPP) -style filter,
exposing these scaling and video post processing options as tunables
therein.

A perfect example of such an implementation that excels in such an
abstraction is intel's vpp_qsv filter, from which multiple compute, color
space conversion methods, tonemapping, etc are made available through
tunables.

Another benefit of such an abstraction would be that re-using this filter
on other GPU derivatives of the discrete silicon, eg in smaller IGPs
sharing these offload blocks would be auto-detecting logic to ensure that
even with defaults, the filter chains run.

Taking another example from Intel, they have a full H/W path for low power
encode and Post-Processing that can be automatically toggled on by specific
filter options without user intervention, guaranteeing runtime safety for
the same command(s) even on newer GPUs.

Food for thought.

>
___
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 8/9] avfilter/scale_amf: Add AMF HW scaler & color converter

2024-02-14 Thread Evgeny Pavlov
On Wed, Feb 14, 2024 at 4:08 PM Timo Rothenpieler 
wrote:

> On 14/02/2024 02:55, Dmitrii Ovchinnikov wrote:
> > From: Evgeny Pavlov 
> >
> > This commit adds two AMF filters: scale_amf & scale_amf_hq.
> > Both filters are using AMF hardware acceleration.
> > scale_amf supports simple scaling algorithms & color conversion.
> > scale_amf_hq supports advanced scaling algorithms & might be used
> > for upscaling only.
>
> Haven't looked at the patch yet, but can't this be one filter, and it
> picks the best possible method depending on options/inputs/whatever?
> ___
> 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".
>

AMF has 2 separate components for color conversion + simple scaling
(VideoConverter)  and for advanced scaling (HQScaler).
We've got a recommendation from the AMD AMF team to implement these
components as separate ffmpeg filters.
___
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 8/9] avfilter/scale_amf: Add AMF HW scaler & color converter

2024-02-14 Thread Timo Rothenpieler

On 14/02/2024 02:55, Dmitrii Ovchinnikov wrote:

From: Evgeny Pavlov 

This commit adds two AMF filters: scale_amf & scale_amf_hq.
Both filters are using AMF hardware acceleration.
scale_amf supports simple scaling algorithms & color conversion.
scale_amf_hq supports advanced scaling algorithms & might be used
for upscaling only.


Haven't looked at the patch yet, but can't this be one filter, and it 
picks the best possible method depending on options/inputs/whatever?

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

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


[FFmpeg-devel] [PATCH] avfilter/avfilter: Fix build with ASSERT_LEVEL >= 1

2024-02-14 Thread Andreas Rheinhardt
Broken in 86417b759f789383ab658e2eb90890477a79eedf.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/avfilter.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 1ea70578c4..9fe249f3f9 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1079,7 +1079,7 @@ static int take_samples(FilterLinkInternal *li, unsigned 
min, unsigned max,
 
 /* Note: this function relies on no format changes and must only be
called with enough samples. */
-av_assert1(samples_ready(link, link->min_samples));
+av_assert1(samples_ready(li, link->min_samples));
 frame0 = frame = ff_framequeue_peek(>fifo, 0);
 if (!li->fifo.samples_skipped && frame->nb_samples >= min && 
frame->nb_samples <= max) {
 *rframe = ff_framequeue_take(>fifo);
@@ -1136,7 +1136,7 @@ static int ff_filter_frame_to_filter(AVFilterLink *link)
 AVFilterContext *dst = link->dst;
 int ret;
 
-av_assert1(ff_framequeue_queued_frames(>fifo));
+av_assert1(ff_framequeue_queued_frames(>fifo));
 ret = link->min_samples ?
   ff_inlink_consume_samples(link, link->min_samples, 
link->max_samples, ) :
   ff_inlink_consume_frame(link, );
@@ -1561,8 +1561,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 void ff_inlink_request_frame(AVFilterLink *link)
 {
-av_assert1(!link->status_in);
-av_assert1(!link->status_out);
+FilterLinkInternal *li = ff_link_internal(link);
+av_assert1(!li->status_in);
+av_assert1(!li->status_out);
 link->frame_wanted_out = 1;
 ff_filter_set_ready(link->src, 100);
 }
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH] checkasm: Add a "run-checkasm" make target

2024-02-14 Thread Martin Storsjö
Contrary to the existing "fate-checkasm", this always prints the
tool output, and runs all tests at once instead of splitting it up
per target group. This is more useful when the user expects to
look directly at the tool output, instead of being part of a full
fate run.

(On failure with the regular "make fate-checkasm" targets, none of
the tool output is printed, but stored in files. If run with reporting
set up to the FATE website, the individual failures are uploaded there,
but if it is run in some sort of other CI setup, the intermediate files
might not be available afterwards for inspection.)
---
 tests/checkasm/Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 3562acb2b2..3af42a679b 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -91,6 +91,10 @@ CHECKASM := tests/checkasm/checkasm$(EXESUF)
 $(CHECKASM): $(CHECKASMOBJS) $(FF_STATIC_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(CHECKASMOBJS) 
$(FF_STATIC_DEP_LIBS) $(EXTRALIBS-avcodec) $(EXTRALIBS-avfilter) 
$(EXTRALIBS-avformat) $(EXTRALIBS-avutil) $(EXTRALIBS-swresample) $(EXTRALIBS)
 
+run-checkasm: $(CHECKASM)
+run-checkasm:
+   $(TARGET_EXEC) $(TARGET_PATH)/$(CHECKASM)
+
 checkasm: $(CHECKASM)
 
 testclean:: checkasmclean
-- 
2.39.3 (Apple Git-145)

___
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] vvcdec: Mark as experimental

2024-02-14 Thread Kieran Kunhya
On Wed, 14 Feb 2024 at 11:47, Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> Kieran Kunhya:
> > From 15c9311c49ebbe87fc4517b67cb73b3079ec3510 Mon Sep 17 00:00:00 2001
> > From: Kieran Kunhya 
> > Date: Wed, 7 Feb 2024 21:10:08 +
> > Subject: [PATCH] vvcdec: Mark as experimental
> >
> > ---
> >  libavcodec/vvc/vvcdec.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/vvc/vvcdec.c b/libavcodec/vvc/vvcdec.c
> > index 8163b5e..e0554c6 100644
> > --- a/libavcodec/vvc/vvcdec.c
> > +++ b/libavcodec/vvc/vvcdec.c
> > @@ -1011,7 +1011,7 @@ const FFCodec ff_vvc_decoder = {
> >  .close  = vvc_decode_free,
> >  FF_CODEC_DECODE_CB(vvc_decode_frame),
> >  .flush  = vvc_decode_flush,
> > -.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_OTHER_THREADS,
> > +.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_EXPERIMENTAL,
> >  .caps_internal  = FF_CODEC_CAP_EXPORTS_CROPPING |
> FF_CODEC_CAP_INIT_CLEANUP |
> >FF_CODEC_CAP_AUTO_THREADS,
> >  .p.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles),
>
> Did you run FATE with that? If I am not mistaken, all the VVC decoding
> tests (and probably also tests where the VVC decoder is only used to get
> stream parameters) will fail (in avcodec_open2()) now, because
> strict_std_compliance does by default not allow experimental codecs.
>

I am aware, it was more to see if there were any objections to the FOSDEM
decision to make it experimental.

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

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


Re: [FFmpeg-devel] [PATCH 1/5] avfilter/vf_signature: Allocate arrays together

2024-02-14 Thread Andreas Rheinhardt
epira...@gmail.com:
> On 14 Feb 2024, at 13:03, Andreas Rheinhardt wrote:
> 
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavfilter/vf_signature.c | 9 ++---
>>  1 file changed, 2 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
>> index 4896e8f2c1..eb48bf773d 100644
>> --- a/libavfilter/vf_signature.c
>> +++ b/libavfilter/vf_signature.c
>> @@ -250,14 +250,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
>> *picref)
>>  int64_t* elemsignature;
>>  uint64_t* sortsignature;
>>
>> -elemsignature = av_malloc_array(elemcat->elem_count, 
>> sizeof(int64_t));
>> +elemsignature = av_malloc_array(elemcat->elem_count, 2 * 
>> sizeof(int64_t));
>>  if (!elemsignature)
>>  return AVERROR(ENOMEM);
>> -sortsignature = av_malloc_array(elemcat->elem_count, 
>> sizeof(int64_t));
>> -if (!sortsignature) {
>> -av_freep();
>> -return AVERROR(ENOMEM);
>> -}
>> +sortsignature = elemsignature + elemcat->elem_count;
> 
> Just my 2cents as someone not maintaining this code, so feel free to ignore 
> completely:
> 
> IMHO this makes it harder to understand what is going on, does it provide any 
> meaningful
> benefit?
> 
> At the very least I would suggest to add a comment for the sake of whoever 
> looks a this
> code next and tries to grasp what is happening there.
> 

The benefit is to have less code; e.g. if the second allocation fails,
one needs to have special cleanup code for the first one.

- 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 1/5] avfilter/vf_signature: Allocate arrays together

2024-02-14 Thread epirat07
On 14 Feb 2024, at 13:03, Andreas Rheinhardt wrote:

> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/vf_signature.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
> index 4896e8f2c1..eb48bf773d 100644
> --- a/libavfilter/vf_signature.c
> +++ b/libavfilter/vf_signature.c
> @@ -250,14 +250,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *picref)
>  int64_t* elemsignature;
>  uint64_t* sortsignature;
>
> -elemsignature = av_malloc_array(elemcat->elem_count, 
> sizeof(int64_t));
> +elemsignature = av_malloc_array(elemcat->elem_count, 2 * 
> sizeof(int64_t));
>  if (!elemsignature)
>  return AVERROR(ENOMEM);
> -sortsignature = av_malloc_array(elemcat->elem_count, 
> sizeof(int64_t));
> -if (!sortsignature) {
> -av_freep();
> -return AVERROR(ENOMEM);
> -}
> +sortsignature = elemsignature + elemcat->elem_count;

Just my 2cents as someone not maintaining this code, so feel free to ignore 
completely:

IMHO this makes it harder to understand what is going on, does it provide any 
meaningful
benefit?

At the very least I would suggest to add a comment for the sake of whoever 
looks a this
code next and tries to grasp what is happening there.

>
>  for (j = 0; j < elemcat->elem_count; j++) {
>  blocksum = 0;
> @@ -307,7 +303,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
> *picref)
>  f++;
>  }
>  av_freep();
> -av_freep();
>  }
>
>  /* confidence */
> -- 
> 2.34.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 5/5] avfilter/signature_lookup: Avoid branch when adding to linked list

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/signature_lookup.c | 16 +---
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index ff0d23c5c7..9c69c02fbf 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -187,7 +187,7 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 size_t i, j, k, l, hmax = 0, score;
 int framerate, offset, l1dist;
 double m;
-MatchingInfo *cands = NULL, *c = NULL;
+MatchingInfo cands = { 0 }, *c = 
 
 struct {
 uint8_t size;
@@ -295,16 +295,10 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 for (i = 0; i < MAX_FRAMERATE; i++) {
 for (j = 0; j < HOUGH_MAX_OFFSET; j++) {
 if (hmax < hspace[i][j].score) {
-if (c == NULL) {
-c = av_malloc(sizeof(MatchingInfo));
-cands = c;
-} else {
-c->next = av_malloc(sizeof(MatchingInfo));
-c = c->next;
-
-}
+c->next = av_malloc(sizeof(MatchingInfo));
+c = c->next;
 if (!c) {
-sll_free();
+sll_free();
 goto error;
 }
 c->framerateratio = (i+1.0) / 30;
@@ -325,7 +319,7 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 error:
 av_freep();
 av_free(hspaces);
-return cands;
+return cands.next;
 }
 
 static int iterate_frame(double frr, FineSignature **a, FineSignature **b, int 
fcount, int *bcount, int dir)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 4/5] avfilter/signature_lookup: Remove useless error logs

2024-02-14 Thread Andreas Rheinhardt
These logs use the wrong loglevel and are uninformative;
and it is of course highly unlikely that a buffer of 56B
can't be allocated.

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

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index 3a42737e1a..ff0d23c5c7 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -297,13 +297,9 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 if (hmax < hspace[i][j].score) {
 if (c == NULL) {
 c = av_malloc(sizeof(MatchingInfo));
-if (!c)
-av_log(ctx, AV_LOG_FATAL, "Could not allocate 
memory");
 cands = c;
 } else {
 c->next = av_malloc(sizeof(MatchingInfo));
-if (!c->next)
-av_log(ctx, AV_LOG_FATAL, "Could not allocate 
memory");
 c = c->next;
 
 }
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 3/5] avfilter/signature_lookup: Allocate buffers jointly

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/signature_lookup.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index 90b1d0eadf..3a42737e1a 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -205,15 +205,17 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 } hspace_elem;
 
 /* houghspace */
-hspace_elem **hspace = av_mallocz(MAX_FRAMERATE * sizeof(*hspace));
+hspace_elem **hspace = av_malloc(MAX_FRAMERATE * sizeof(*hspace));
+hspace_elem *hspaces;
 
 if (!hspace)
 return NULL;
 /* initialize houghspace */
+hspaces = av_malloc((2 * HOUGH_MAX_OFFSET + 1) * sizeof(*hspaces) * 
MAX_FRAMERATE);
+if (!hspaces)
+goto error;
 for (i = 0; i < MAX_FRAMERATE; i++) {
-hspace[i] = av_malloc_array(2 * HOUGH_MAX_OFFSET + 1, 
sizeof(hspace_elem));
-if (!hspace[i])
-goto error;
+hspace[i] = hspaces + i * (2 * HOUGH_MAX_OFFSET + 1);
 for (j = 0; j < 2 * HOUGH_MAX_OFFSET + 1; j++) {
 hspace[i][j].score = 0;
 hspace[i][j].dist = 9;
@@ -325,10 +327,8 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 }
 }
 error:
-for (i = 0; i < MAX_FRAMERATE; i++) {
-av_freep([i]);
-}
 av_freep();
+av_free(hspaces);
 return cands;
 }
 
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/5] avfilter/signature_lookup: Check for allocation error

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/signature_lookup.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
index ad012ecced..90b1d0eadf 100644
--- a/libavfilter/signature_lookup.c
+++ b/libavfilter/signature_lookup.c
@@ -205,11 +205,15 @@ static MatchingInfo* 
get_matching_parameters(AVFilterContext *ctx, SignatureCont
 } hspace_elem;
 
 /* houghspace */
-hspace_elem** hspace = av_malloc_array(MAX_FRAMERATE, sizeof(hspace_elem 
*));
+hspace_elem **hspace = av_mallocz(MAX_FRAMERATE * sizeof(*hspace));
 
+if (!hspace)
+return NULL;
 /* initialize houghspace */
 for (i = 0; i < MAX_FRAMERATE; i++) {
 hspace[i] = av_malloc_array(2 * HOUGH_MAX_OFFSET + 1, 
sizeof(hspace_elem));
+if (!hspace[i])
+goto error;
 for (j = 0; j < 2 * HOUGH_MAX_OFFSET + 1; j++) {
 hspace[i][j].score = 0;
 hspace[i][j].dist = 9;
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/5] avfilter/vf_signature: Allocate arrays together

2024-02-14 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/vf_signature.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 4896e8f2c1..eb48bf773d 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -250,14 +250,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 int64_t* elemsignature;
 uint64_t* sortsignature;
 
-elemsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
+elemsignature = av_malloc_array(elemcat->elem_count, 2 * 
sizeof(int64_t));
 if (!elemsignature)
 return AVERROR(ENOMEM);
-sortsignature = av_malloc_array(elemcat->elem_count, sizeof(int64_t));
-if (!sortsignature) {
-av_freep();
-return AVERROR(ENOMEM);
-}
+sortsignature = elemsignature + elemcat->elem_count;
 
 for (j = 0; j < elemcat->elem_count; j++) {
 blocksum = 0;
@@ -307,7 +303,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 f++;
 }
 av_freep();
-av_freep();
 }
 
 /* confidence */
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] vvcdec: Mark as experimental

2024-02-14 Thread Andreas Rheinhardt
Kieran Kunhya:
> From 15c9311c49ebbe87fc4517b67cb73b3079ec3510 Mon Sep 17 00:00:00 2001
> From: Kieran Kunhya 
> Date: Wed, 7 Feb 2024 21:10:08 +
> Subject: [PATCH] vvcdec: Mark as experimental
> 
> ---
>  libavcodec/vvc/vvcdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vvc/vvcdec.c b/libavcodec/vvc/vvcdec.c
> index 8163b5e..e0554c6 100644
> --- a/libavcodec/vvc/vvcdec.c
> +++ b/libavcodec/vvc/vvcdec.c
> @@ -1011,7 +1011,7 @@ const FFCodec ff_vvc_decoder = {
>  .close  = vvc_decode_free,
>  FF_CODEC_DECODE_CB(vvc_decode_frame),
>  .flush  = vvc_decode_flush,
> -.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | 
> AV_CODEC_CAP_OTHER_THREADS,
> +.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | 
> AV_CODEC_CAP_OTHER_THREADS | AV_CODEC_CAP_EXPERIMENTAL,
>  .caps_internal  = FF_CODEC_CAP_EXPORTS_CROPPING | 
> FF_CODEC_CAP_INIT_CLEANUP |
>FF_CODEC_CAP_AUTO_THREADS,
>  .p.profiles = NULL_IF_CONFIG_SMALL(ff_vvc_profiles),

Did you run FATE with that? If I am not mistaken, all the VVC decoding
tests (and probably also tests where the VVC decoder is only used to get
stream parameters) will fail (in avcodec_open2()) now, because
strict_std_compliance does by default not allow experimental codecs.

- 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] avcodec/vvcdec: frame_context_setup, set fc->ref to NULL

2024-02-14 Thread Anton Khirnov
Quoting Frank Plowman (2024-02-13 11:38:50)
> Btw, I don't think you should add Signed-off-by tags for other people.
> Their exact meaning varies by project and I am not sure of their meaning
> in FFmpeg (if there is one),

There is no officially accepted one.

E.g. I add my signoff to patches I push where I'm not the author.

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

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


Re: [FFmpeg-devel] [PATCH] lavc/aarch64/fdct: add neon-optimized fdct for aarch64

2024-02-14 Thread Martin Storsjö

Hi,

On Sun, 4 Feb 2024, Ramiro Polla wrote:


The code is imported from libjpeg-turbo-3.0.1. The neon registers used
have been changed to avoid modifying v8-v15.
---


I don't remember if we have any extra routines we need to do if importing 
foreign code with a differing license. The license here seems fine in any 
case though.


This seems to work fine in all my test environments. And thanks for making 
sure it doesn't use v8-v15!


I'm not so familiar with these DSP functions, whether it is norm to add a 
new constant like FF_DCT_NEON, but I guess it seems to match the pattern 
of the existing code.



I presume the main case that tests this is "make fate-dct8x8", which 
builds and executes libavcodec/tests/dct? How much work would it be to 
integrate testing of these routines into checkasm? That way we could rest 
assured that the assembly passes all such ABI checks that we do there, 
including what registers must not be clobbered.



The assembly uses a different indentation width than the rest of our 
assembly. I recently spent some effort on cleaning that up so that our 
code is mostly consistent, so I'd prefer not to add new code that deviates 
from it. It primarily looks like you'd need to add 4 spaces at the start 
of each line.


I've used a script for mostly automatically reindenting our arm assembly, 
you can grab it at https://martin.st/temp/ffmpeg-asm-indent.pl, run it as 
"cat file.S | ./ffmpeg-asm-indent.pl > tmp; mv tmp file.S". It's not 100% 
accurate, but mostly gets you there, but it's good to manually check it 
afterwards as well.


// Martin

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

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


Re: [FFmpeg-devel] [PATCH] vvcdec: Mark as experimental

2024-02-14 Thread Kieran Kunhya
On Wed, 14 Feb 2024, 02:58 Nuo Mi,  wrote:

> >
> >
> >>>
> >>> If there are no objections, I'll push it tomorrow.
> > thank you, Kieran and Paul.
> >
> Hi Kieran,
> Patchwork didn't get your patch.
> I've checked the fate status locally, and it indicates that "make fate-vvc"
> will fail.
> Could you please send a new one to the patchwork?
>
> Thank you.
>

I am not sure how to do that on Windows unfortunately. Patchwork doesn't
seem to support attachment patches.

Kieran

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