[FFmpeg-devel] [PATCH] avcodec/decode: log hwaccel name

2024-03-13 Thread Zhao Zhili
From: Zhao Zhili 

Many users mistakenly think that hwaccel is an instance of a decoder,
and cannot find the corresponding decoder name in the logs. Log
hwaccel name so user know hwaccel has taken effect.
---
 libavcodec/decode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 7c67b18bc4..d01b8a04f1 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1371,8 +1371,8 @@ int ff_get_format(AVCodecContext *avctx, const enum 
AVPixelFormat *fmt)
 goto try_again;
 }
 if (hw_config->hwaccel) {
-av_log(avctx, AV_LOG_DEBUG, "Format %s requires hwaccel "
-   "initialisation.\n", desc->name);
+av_log(avctx, AV_LOG_DEBUG, "Format %s requires hwaccel %s "
+   "initialisation.\n", desc->name, 
hw_config->hwaccel->p.name);
 err = hwaccel_init(avctx, hw_config->hwaccel);
 if (err < 0)
 goto try_again;
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH v1] lavc/vaapi_decode: Don't update buffer number if allocataion fail

2024-03-13 Thread fei . w . wang-at-intel . com
From: Fei Wang 

Signed-off-by: Fei Wang 
---
 libavcodec/vaapi_decode.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index ceac769c52..cca94b5336 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -72,17 +72,14 @@ int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
 
 av_assert0(pic->nb_slices <= pic->slices_allocated);
 if (pic->nb_slices == pic->slices_allocated) {
-if (pic->slices_allocated > 0)
-pic->slices_allocated *= 2;
-else
-pic->slices_allocated = 64;
-
 pic->slice_buffers =
 av_realloc_array(pic->slice_buffers,
- pic->slices_allocated,
+ pic->slices_allocated ? pic->slices_allocated * 2 
: 64,
  2 * sizeof(*pic->slice_buffers));
 if (!pic->slice_buffers)
 return AVERROR(ENOMEM);
+
+pic->slices_allocated = pic->slices_allocated ? pic->slices_allocated 
* 2 : 64;
 }
 av_assert0(pic->nb_slices + 1 <= pic->slices_allocated);
 
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 3/3] avformat/aiffenc: Usw avio_wb32() where possible

2024-03-13 Thread Andreas Rheinhardt
AIFF is a big-endian format, so this is more natural.

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

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 37aca41847..2cd1119409 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -54,7 +54,7 @@ static int put_id3v2_tags(AVFormatContext *s, 
AIFFOutputContext *aiff)
 if (!s->metadata && !s->nb_chapters && !list_entry)
 return 0;
 
-avio_wl32(pb, MKTAG('I', 'D', '3', ' '));
+avio_wb32(pb, MKBETAG('I', 'D', '3', ' '));
 avio_wb32(pb, 0);
 pos = avio_tell(pb);
 
@@ -93,7 +93,7 @@ static void put_meta(AVFormatContext *s, const char *key, 
uint32_t id)
 // So simply copy the terminating \0 if the length is odd.
 size = FFALIGN(size, 2);
 
-avio_wl32(pb, id);
+avio_wb32(pb, id);
 avio_wb32(pb, size);
 avio_write(pb, tag->value, size);
 }
@@ -153,10 +153,10 @@ static int aiff_write_header(AVFormatContext *s)
 ff_mov_write_chan(pb, par->ch_layout.u.mask);
 }
 
-put_meta(s, "title", MKTAG('N', 'A', 'M', 'E'));
-put_meta(s, "author",MKTAG('A', 'U', 'T', 'H'));
-put_meta(s, "copyright", MKTAG('(', 'c', ')', ' '));
-put_meta(s, "comment",   MKTAG('A', 'N', 'N', 'O'));
+put_meta(s, "title", MKBETAG('N', 'A', 'M', 'E'));
+put_meta(s, "author",MKBETAG('A', 'U', 'T', 'H'));
+put_meta(s, "copyright", MKBETAG('(', 'c', ')', ' '));
+put_meta(s, "comment",   MKBETAG('A', 'N', 'N', 'O'));
 
 /* Common chunk */
 ffio_wfourcc(pb, "COMM");
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 2/3] avformat/aiffenc: Simplify padding tag

2024-03-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/aiffenc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index 11a5b18d57..37aca41847 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -87,13 +87,15 @@ static void put_meta(AVFormatContext *s, const char *key, 
uint32_t id)
 AVIOContext *pb = s->pb;
 
 if (tag = av_dict_get(s->metadata, key, NULL, 0)) {
-int size = strlen(tag->value);
+size_t size = strlen(tag->value);
+
+// AIFF tags are zero-padded to an even length.
+// So simply copy the terminating \0 if the length is odd.
+size = FFALIGN(size, 2);
 
 avio_wl32(pb, id);
-avio_wb32(pb, FFALIGN(size, 2));
+avio_wb32(pb, size);
 avio_write(pb, tag->value, size);
-if (size & 1)
-avio_w8(pb, 0);
 }
 }
 
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 1/3] fate/lavf-audio: Test writing AIFF-native tags

2024-03-13 Thread Andreas Rheinhardt
In particular, test writing tags with odd strlen.
(These tags are zero-padded to even size.)

Signed-off-by: Andreas Rheinhardt 
---
 tests/fate/lavf-audio.mak | 1 +
 tests/ref/lavf/aiff   | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/fate/lavf-audio.mak b/tests/fate/lavf-audio.mak
index d54cd107e0..7ea0c41da9 100644
--- a/tests/fate/lavf-audio.mak
+++ b/tests/fate/lavf-audio.mak
@@ -28,6 +28,7 @@ $(FATE_LAVF_AUDIO): CMD = lavf_audio
 $(FATE_LAVF_AUDIO): REF = $(SRC_PATH)/tests/ref/lavf/$(@:fate-lavf-%=%)
 $(FATE_LAVF_AUDIO): $(AREF)
 
+fate-lavf-aiff: CMD = lavf_audio "" "-metadata copyright=noone"
 fate-lavf-al fate-lavf-ul: CMD = lavf_audio "" "" "-ar 44100"
 fate-lavf-dfpwm: CMD = lavf_audio "" "" "-sample_rate 44100"
 fate-lavf-ogg: CMD = lavf_audio "" "-c:a flac"
diff --git a/tests/ref/lavf/aiff b/tests/ref/lavf/aiff
index d72ec85150..e208ff3e16 100644
--- a/tests/ref/lavf/aiff
+++ b/tests/ref/lavf/aiff
@@ -1,3 +1,3 @@
-2c129d88acef834e32869145fe792b9c *tests/data/lavf/lavf.aiff
-88270 tests/data/lavf/lavf.aiff
+655b5bd68e7a59599ab6663de0015324 *tests/data/lavf/lavf.aiff
+88284 tests/data/lavf/lavf.aiff
 tests/data/lavf/lavf.aiff CRC=0x3a1da17e
-- 
2.40.1

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Michael Niedermayer
On Wed, Mar 13, 2024 at 08:43:58PM -0300, James Almer wrote:
> On 3/13/2024 8:41 PM, Michael Niedermayer wrote:
> > On Wed, Mar 13, 2024 at 01:24:25PM +0100, Niklas Haas wrote:
> > > From: Niklas Haas 
> > > 
> > > This filter's existing design has a number of issues:
> > > 
> > > - There is no guarantee whatsoever about the order in which frames are
> > >pushed onto the main and ref link, due to this being entirely
> > >dependent on the order in which downstream filters decide to request
> > >frames from their various inputs. As such, there is absolutely no
> > >synchronization for ref streams with dynamically changing resolutions
> > >(see e.g. fate/h264/reinit-*).
> > > 
> > > - For some (likely historical) reason, this filter outputs its ref
> > >stream as a second ref output, which is in principle completely
> > >unnecessary (complex filter graph users can just duplicate the input
> > >pin), but in practice only required to allow this filter to
> > >"eventually" see changes to the ref stream (see first point). In
> > >particular, this means that if the user uses the "wrong" pin, this
> > >filter may break completely.
> > > 
> > > - The default filter activation function is fundamentally incapable of
> > >handling filters with multiple inputs cleanly, because doing so
> > >requires both knowledge of how these inputs should be internally
> > >ordered, but also how to handle EOF conditions on either input (or
> > >downstream). Both of these are best left to the filter specific
> > >options. (See #10795 for the consequences of using the default
> > >activate with multiple inputs).
> > > 
> > > Switching this filter to framesync fixes all three points:
> > > 
> > > - ff_framesync_activate() correctly handles multiple inputs and EOF
> > >conditions (and is configurable with the framesync-specific options)
> > > - framesync only supports a single output, so we can (indeed must) drop
> > >the redundant ref output stream
> > > 
> > > Update documentation, changelog and tests to correspond to the new usage
> > > pattern.
> > > 
> > > Fixes: https://trac.ffmpeg.org/ticket/10795
> > > ---
> > >   Changelog|   2 +
> > >   doc/filters.texi |  10 +-
> > >   libavfilter/vf_scale.c   | 130 ---
> > >   tests/filtergraphs/scale2ref_keep_aspect |   3 +-
> > >   4 files changed, 76 insertions(+), 69 deletions(-)
> > 
> > this causes
> > ./ffplay --help
> > to segfault
> 
> Unrelated to this crash, but why does that command line output every single
> option from every single filter? It's several thousand printed lines.
> Shouldn't that be the output of --longhelp or similar, and leave --help to
> print some basic non filter specific options?

I think the help handling should be consistent between the tools, iam not sure
why it is not currently

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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

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


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Andreas Rheinhardt
Niklas Haas:
> From: Niklas Haas 
> 
> This filter's existing design has a number of issues:
> 
> - There is no guarantee whatsoever about the order in which frames are
>   pushed onto the main and ref link, due to this being entirely
>   dependent on the order in which downstream filters decide to request
>   frames from their various inputs. As such, there is absolutely no
>   synchronization for ref streams with dynamically changing resolutions
>   (see e.g. fate/h264/reinit-*).
> 
> - For some (likely historical) reason, this filter outputs its ref
>   stream as a second ref output, which is in principle completely
>   unnecessary (complex filter graph users can just duplicate the input
>   pin), but in practice only required to allow this filter to
>   "eventually" see changes to the ref stream (see first point). In
>   particular, this means that if the user uses the "wrong" pin, this
>   filter may break completely.
> 
> - The default filter activation function is fundamentally incapable of
>   handling filters with multiple inputs cleanly, because doing so
>   requires both knowledge of how these inputs should be internally
>   ordered, but also how to handle EOF conditions on either input (or
>   downstream). Both of these are best left to the filter specific
>   options. (See #10795 for the consequences of using the default
>   activate with multiple inputs).
> 
> Switching this filter to framesync fixes all three points:
> 
> - ff_framesync_activate() correctly handles multiple inputs and EOF
>   conditions (and is configurable with the framesync-specific options)
> - framesync only supports a single output, so we can (indeed must) drop
>   the redundant ref output stream
> 
> Update documentation, changelog and tests to correspond to the new usage
> pattern.
> 
> Fixes: https://trac.ffmpeg.org/ticket/10795
> ---
>  Changelog|   2 +
>  doc/filters.texi |  10 +-
>  libavfilter/vf_scale.c   | 130 ---
>  tests/filtergraphs/scale2ref_keep_aspect |   3 +-
>  4 files changed, 76 insertions(+), 69 deletions(-)
> 
> diff --git a/Changelog b/Changelog
> index 069b8274489..bacda2524ea 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -32,6 +32,8 @@ version :
>  - DVD-Video demuxer, powered by libdvdnav and libdvdread
>  - ffprobe -show_stream_groups option
>  - ffprobe (with -export_side_data film_grain) now prints film grain metadata
> +- scale2ref now only has a single output stream, and supports the framesync
> +  options
>  
>  
>  version 6.1:
> diff --git a/doc/filters.texi b/doc/filters.texi
> index e0436a5755c..07e8136adb3 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -21555,9 +21555,9 @@ Deprecated, do not use.
>  Scale (resize) the input video, based on a reference video.
>  
>  See the scale filter for available options, scale2ref supports the same but
> -uses the reference video instead of the main input as basis. scale2ref also
> -supports the following additional constants for the @option{w} and
> -@option{h} options:
> +uses the reference video instead of the main input as basis. This filter also
> +supports the @ref{framesync} options. In addition, scale2ref also supports 
> the
> +following additional constants for the @option{w} and @option{h} options:
>  
>  @table @var
>  @item main_w
> @@ -21600,13 +21600,13 @@ Only available with @code{eval=frame}.
>  @item
>  Scale a subtitle stream (b) to match the main video (a) in size before 
> overlaying
>  @example
> -'scale2ref[b][a];[a][b]overlay'
> +'[b][a]scale2ref[sub];[a][sub]overlay'
>  @end example
>  
>  @item
>  Scale a logo to 1/10th the height of a video, while preserving its display 
> aspect ratio.
>  @example
> -[logo-in][video-in]scale2ref=w=oh*mdar:h=ih/10[logo-out][video-out]
> +[logo-in][video]scale2ref=w=oh*mdar:h=ih/10[logo-out]
>  @end example
>  @end itemize
>  
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index fc3b5a91e60..d4173b63097 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -29,6 +29,7 @@
>  
>  #include "avfilter.h"
>  #include "formats.h"
> +#include "framesync.h"
>  #include "internal.h"
>  #include "scale_eval.h"
>  #include "video.h"
> @@ -114,6 +115,7 @@ typedef struct ScaleContext {
>  struct SwsContext *isws[2]; ///< software scaler context for interlaced 
> material
>  // context used for forwarding options to sws
>  struct SwsContext *sws_opts;
> +FFFrameSync fs; ///< for scale2ref
>  
>  /**
>   * New dimensions. Special values are:
> @@ -288,6 +290,9 @@ static av_cold int preinit(AVFilterContext *ctx)
>  if (ret < 0)
>  return ret;
>  
> +if (ctx->filter == _vf_scale2ref)
> +ff_framesync_preinit(>fs);
> +
>  return 0;
>  }
>  
> @@ -303,6 +308,8 @@ static const int sws_colorspaces[] = {
>  -1
>  };
>  
> +static int do_scale2ref(FFFrameSync *fs);
> +
>  static av_cold int init(AVFilterContext 

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread James Almer

On 3/13/2024 8:41 PM, Michael Niedermayer wrote:

On Wed, Mar 13, 2024 at 01:24:25PM +0100, Niklas Haas wrote:

From: Niklas Haas 

This filter's existing design has a number of issues:

- There is no guarantee whatsoever about the order in which frames are
   pushed onto the main and ref link, due to this being entirely
   dependent on the order in which downstream filters decide to request
   frames from their various inputs. As such, there is absolutely no
   synchronization for ref streams with dynamically changing resolutions
   (see e.g. fate/h264/reinit-*).

- For some (likely historical) reason, this filter outputs its ref
   stream as a second ref output, which is in principle completely
   unnecessary (complex filter graph users can just duplicate the input
   pin), but in practice only required to allow this filter to
   "eventually" see changes to the ref stream (see first point). In
   particular, this means that if the user uses the "wrong" pin, this
   filter may break completely.

- The default filter activation function is fundamentally incapable of
   handling filters with multiple inputs cleanly, because doing so
   requires both knowledge of how these inputs should be internally
   ordered, but also how to handle EOF conditions on either input (or
   downstream). Both of these are best left to the filter specific
   options. (See #10795 for the consequences of using the default
   activate with multiple inputs).

Switching this filter to framesync fixes all three points:

- ff_framesync_activate() correctly handles multiple inputs and EOF
   conditions (and is configurable with the framesync-specific options)
- framesync only supports a single output, so we can (indeed must) drop
   the redundant ref output stream

Update documentation, changelog and tests to correspond to the new usage
pattern.

Fixes: https://trac.ffmpeg.org/ticket/10795
---
  Changelog|   2 +
  doc/filters.texi |  10 +-
  libavfilter/vf_scale.c   | 130 ---
  tests/filtergraphs/scale2ref_keep_aspect |   3 +-
  4 files changed, 76 insertions(+), 69 deletions(-)


this causes
./ffplay --help
to segfault


Unrelated to this crash, but why does that command line output every 
single option from every single filter? It's several thousand printed 
lines. Shouldn't that be the output of --longhelp or similar, and leave 
--help to print some basic non filter specific options?

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Michael Niedermayer
On Wed, Mar 13, 2024 at 01:24:25PM +0100, Niklas Haas wrote:
> From: Niklas Haas 
> 
> This filter's existing design has a number of issues:
> 
> - There is no guarantee whatsoever about the order in which frames are
>   pushed onto the main and ref link, due to this being entirely
>   dependent on the order in which downstream filters decide to request
>   frames from their various inputs. As such, there is absolutely no
>   synchronization for ref streams with dynamically changing resolutions
>   (see e.g. fate/h264/reinit-*).
> 
> - For some (likely historical) reason, this filter outputs its ref
>   stream as a second ref output, which is in principle completely
>   unnecessary (complex filter graph users can just duplicate the input
>   pin), but in practice only required to allow this filter to
>   "eventually" see changes to the ref stream (see first point). In
>   particular, this means that if the user uses the "wrong" pin, this
>   filter may break completely.
> 
> - The default filter activation function is fundamentally incapable of
>   handling filters with multiple inputs cleanly, because doing so
>   requires both knowledge of how these inputs should be internally
>   ordered, but also how to handle EOF conditions on either input (or
>   downstream). Both of these are best left to the filter specific
>   options. (See #10795 for the consequences of using the default
>   activate with multiple inputs).
> 
> Switching this filter to framesync fixes all three points:
> 
> - ff_framesync_activate() correctly handles multiple inputs and EOF
>   conditions (and is configurable with the framesync-specific options)
> - framesync only supports a single output, so we can (indeed must) drop
>   the redundant ref output stream
> 
> Update documentation, changelog and tests to correspond to the new usage
> pattern.
> 
> Fixes: https://trac.ffmpeg.org/ticket/10795
> ---
>  Changelog|   2 +
>  doc/filters.texi |  10 +-
>  libavfilter/vf_scale.c   | 130 ---
>  tests/filtergraphs/scale2ref_keep_aspect |   3 +-
>  4 files changed, 76 insertions(+), 69 deletions(-)

this causes
./ffplay --help
to segfault

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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

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


[FFmpeg-devel] [PATCH 6/7] avcodec/vorbis_data: Mark symbols as hidden

2024-03-13 Thread Andreas Rheinhardt
Avoids .got entries for ff_vorbis_ch_layouts.

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

diff --git a/libavcodec/vorbis_data.h b/libavcodec/vorbis_data.h
index 51c91c9e04..327e5ab2ef 100644
--- a/libavcodec/vorbis_data.h
+++ b/libavcodec/vorbis_data.h
@@ -21,11 +21,14 @@
 
 #include 
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/channel_layout.h"
 
+FF_VISIBILITY_PUSH_HIDDEN
 extern const float ff_vorbis_floor1_inverse_db_table[256];
 extern const float * const ff_vorbis_vwin[8];
 extern const uint8_t ff_vorbis_channel_layout_offsets[8][8];
 extern const AVChannelLayout ff_vorbis_ch_layouts[9];
+FF_VISIBILITY_POP_HIDDEN
 
 #endif /* AVCODEC_VORBIS_DATA_H */
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 7/7] avcodec/mpegaudio(data|dsp): Mark symbols as hidden

2024-03-13 Thread Andreas Rheinhardt
Avoids .got entries for ff_mpa_bitrate_tab, ff_mpa_synth_window_fixed,
ff_band_size_long, ff_mpa_pretab, ff_band_size_short,
ff_mpa_synth_window_float and ff_band_index_long here.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpegaudiodata.h | 3 +++
 libavcodec/mpegaudiodsp.h  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/libavcodec/mpegaudiodata.h b/libavcodec/mpegaudiodata.h
index fbad67a0b3..720c4bee64 100644
--- a/libavcodec/mpegaudiodata.h
+++ b/libavcodec/mpegaudiodata.h
@@ -31,11 +31,13 @@
 
 #include "config.h"
 
+#include "libavutil/attributes_internal.h"
 #include "vlc.h"
 
 #define MODE_EXT_MS_STEREO 2
 #define MODE_EXT_I_STEREO  1
 
+FF_VISIBILITY_PUSH_HIDDEN
 extern const uint16_t ff_mpa_bitrate_tab[2][3][15];
 extern const uint16_t ff_mpa_freq_tab[3];
 extern const int ff_mpa_sblimit_table[5];
@@ -78,5 +80,6 @@ extern const uint8_t ff_mpa_pretab[2][22];
 /* Initialize tables shared between the fixed and
  * floating point MPEG audio decoders. */
 void ff_mpegaudiodec_common_init_static(void);
+FF_VISIBILITY_POP_HIDDEN
 
 #endif /* AVCODEC_MPEGAUDIODATA_H */
diff --git a/libavcodec/mpegaudiodsp.h b/libavcodec/mpegaudiodsp.h
index 7bc635191a..5e47a263bb 100644
--- a/libavcodec/mpegaudiodsp.h
+++ b/libavcodec/mpegaudiodsp.h
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/macros.h"
 
 typedef struct MPADSPContext {
@@ -40,6 +41,7 @@ typedef struct MPADSPContext {
  int count, int switch_point, int block_type);
 } MPADSPContext;
 
+FF_VISIBILITY_PUSH_HIDDEN
 void ff_mpadsp_init(MPADSPContext *s);
 
 extern int32_t ff_mpa_synth_window_fixed[];
@@ -88,5 +90,6 @@ void ff_imdct36_blocks_fixed(int *out, int *buf, int *in,
 
 extern int ff_mdct_win_fixed[8][MDCT_BUF_SIZE];
 extern float ff_mdct_win_float[8][MDCT_BUF_SIZE];
+FF_VISIBILITY_POP_HIDDEN
 
 #endif /* AVCODEC_MPEGAUDIODSP_H */
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 5/7] avcodec/dirac_arith: Only include x86/asm.h for ARCH_X86

2024-03-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dirac_arith.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/dirac_arith.h b/libavcodec/dirac_arith.h
index 350a58fca6..203d481603 100644
--- a/libavcodec/dirac_arith.h
+++ b/libavcodec/dirac_arith.h
@@ -28,7 +28,11 @@
 #ifndef AVCODEC_DIRAC_ARITH_H
 #define AVCODEC_DIRAC_ARITH_H
 
+#include "config.h"
+
+#if ARCH_X86
 #include "libavutil/x86/asm.h"
+#endif
 #include "bytestream.h"
 #include "get_bits.h"
 
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 4/7] avdevice/alldevices: Mark iterators as av_cold

2024-03-13 Thread Andreas Rheinhardt
Because they are.

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

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 6396076ecf..9b9a9146c7 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/attributes.h"
 #include "libavutil/attributes_internal.h"
 #include "libavformat/demux.h"
 #include "libavformat/internal.h"
@@ -66,12 +67,12 @@ FF_VISIBILITY_POP_HIDDEN
 #include "libavdevice/outdev_list.c"
 #include "libavdevice/indev_list.c"
 
-void avdevice_register_all(void)
+av_cold void avdevice_register_all(void)
 {
 avpriv_register_devices(outdev_list, indev_list);
 }
 
-static const void *next_input(const AVInputFormat *prev, AVClassCategory c2)
+static av_cold const void *next_input(const AVInputFormat *prev, 
AVClassCategory c2)
 {
 const AVClass *pc;
 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT;
@@ -97,7 +98,7 @@ static const void *next_input(const AVInputFormat *prev, 
AVClassCategory c2)
 return fmt;
 }
 
-static const void *next_output(const AVOutputFormat *prev, AVClassCategory c2)
+static av_cold const void *next_output(const AVOutputFormat *prev, 
AVClassCategory c2)
 {
 const AVClass *pc;
 const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT;
@@ -123,22 +124,22 @@ static const void *next_output(const AVOutputFormat 
*prev, AVClassCategory c2)
 return fmt;
 }
 
-const AVInputFormat *av_input_audio_device_next(const AVInputFormat  *d)
+av_cold const AVInputFormat *av_input_audio_device_next(const AVInputFormat  
*d)
 {
 return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT);
 }
 
-const AVInputFormat *av_input_video_device_next(const AVInputFormat  *d)
+av_cold const AVInputFormat *av_input_video_device_next(const AVInputFormat  
*d)
 {
 return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT);
 }
 
-const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat *d)
+av_cold const AVOutputFormat *av_output_audio_device_next(const AVOutputFormat 
*d)
 {
 return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT);
 }
 
-const AVOutputFormat *av_output_video_device_next(const AVOutputFormat *d)
+av_cold const AVOutputFormat *av_output_video_device_next(const AVOutputFormat 
*d)
 {
 return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT);
 }
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 3/7] avdevice/alldevices: Mark devices as hidden

2024-03-13 Thread Andreas Rheinhardt
Both GCC and Clang create code that inlines the loops in
next_input() and next_output() at high optimization
levels (presumably when there are not too many devices)
and this code leads to the creation of .got entries:
  e7:   48 3b 3d 00 00 00 00cmp0x0(%rip),%rdi# ee 

ea: R_X86_64_REX_GOTPCRELX  ff_alsa_demuxer-0x4
  ee:   74 43   je 133 
  f0:   48 3b 3d 00 00 00 00cmp0x0(%rip),%rdi# f7 

f3: R_X86_64_REX_GOTPCRELX  ff_fbdev_demuxer-0x4
  f7:   74 41   je 13a 

These relocations can't be fixed up lateron when it is known
that the symbols exist in the same DSO.

This commit therefore marks these symbols as hidden, leading
to code like this:
  f7:   48 8d 05 00 00 00 00lea0x0(%rip),%rax# fe 

fa: R_X86_64_PC32   ff_alsa_demuxer-0x4
  fe:   48 39 c7cmp%rax,%rdi
 101:   74 55   je 158 
 103:   48 8d 05 00 00 00 00lea0x0(%rip),%rax# 10a 

106: R_X86_64_PC32  ff_fbdev_demuxer-0x4
 10a:   48 39 c7cmp%rax,%rdi
 10d:   74 50   je 15f 

(Note: It is actually strange that the compiler creates code
that tries to read the addresses from the .got given that the
addresses can be read directly from indev_list/outdev_list.)

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

diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 5ee97c56b6..6396076ecf 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -18,11 +18,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/attributes_internal.h"
 #include "libavformat/demux.h"
 #include "libavformat/internal.h"
 #include "libavformat/mux.h"
 #include "avdevice.h"
 
+FF_VISIBILITY_PUSH_HIDDEN
 /* devices */
 extern const FFInputFormat  ff_alsa_demuxer;
 extern const FFOutputFormat ff_alsa_muxer;
@@ -59,6 +61,7 @@ extern const FFOutputFormat ff_xv_muxer;
 /* external libraries */
 extern const FFInputFormat  ff_libcdio_demuxer;
 extern const FFInputFormat  ff_libdc1394_demuxer;
+FF_VISIBILITY_POP_HIDDEN
 
 #include "libavdevice/outdev_list.c"
 #include "libavdevice/indev_list.c"
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 2/7] avcodec/ac3tab: Remove enum CustomChannelMapLocation

2024-03-13 Thread Andreas Rheinhardt
Forgotten in 4c8d9b1d0901b0fba0887e53463574913e8862c5.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3tab.h | 16 
 1 file changed, 16 deletions(-)

diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index 2531d80677..dcef643acb 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -45,22 +45,6 @@ extern const uint8_t  
ff_ac3_band_start_tab[AC3_CRITICAL_BANDS+1];
 extern const uint8_t  ff_ac3_bin_to_band_tab[253];
 extern const uint64_t ff_eac3_custom_channel_map_locations[16][2];
 
-
-/** Custom channel map locations bitmask
- *  Other channels described in documentation:
- *  Lc/Rc pair, Lrs/Rrs pair, Ts, Lsd/Rsd pair,
- *  Lw/Rw pair, Lvh/Rvh pair, Cvh, Reserved, LFE2
- */
-enum CustomChannelMapLocation{
-AC3_CHMAP_L=1<<(15-0),
-AC3_CHMAP_C=1<<(15-1),
-AC3_CHMAP_R=1<<(15-2),
-AC3_CHMAP_L_SUR=1<<(15-3),
-AC3_CHMAP_R_SUR =   1<<(15-4),
-AC3_CHMAP_C_SUR=1<<(15-7),
-AC3_CHMAP_LFE = 1<<(15-15)
-};
-
 #define COMMON_CHANNEL_MAP \
 { { 0, 1,  }, { 0, 1, 2, } },\
 { { 0, }, { 0, 1,} },\
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH 1/7] avformat/iamf: Mark symbols as hidden

2024-03-13 Thread Andreas Rheinhardt
Avoids .got entries for ff_iamf_scalable_ch_layouts and
ff_iamf_sound_system_map (whether they would have been
created otherwise depends upon the compiler and compiler
options).

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/iamf.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/iamf.h b/libavformat/iamf.h
index d662f6e76b..68f05c635b 100644
--- a/libavformat/iamf.h
+++ b/libavformat/iamf.h
@@ -25,6 +25,7 @@
 #include 
 #include 
 
+#include "libavutil/attributes_internal.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/iamf.h"
 #include "libavcodec/codec_id.h"
@@ -162,6 +163,7 @@ struct IAMFSoundSystemMap {
 AVChannelLayout layout;
 };
 
+FF_VISIBILITY_PUSH_HIDDEN
 extern const AVChannelLayout ff_iamf_scalable_ch_layouts[10];
 extern const struct IAMFSoundSystemMap ff_iamf_sound_system_map[13];
 
@@ -195,5 +197,6 @@ static inline IAMFParamDefinition 
*ff_iamf_get_param_definition(const IAMFContex
 void ff_iamf_free_audio_element(IAMFAudioElement **paudio_element);
 void ff_iamf_free_mix_presentation(IAMFMixPresentation **pmix_presentation);
 void ff_iamf_uninit_context(IAMFContext *c);
+FF_VISIBILITY_POP_HIDDEN
 
 #endif /* AVFORMAT_IAMF_H */
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH] avutil/hwcontext_d3d11va: add logging to d3d11/dxgi interfaces

2024-03-13 Thread Timo Rothenpieler
---
 libavutil/hwcontext_d3d11va.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index cf793a2f48..522c15a58b 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -616,8 +616,12 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, 
const char *device,
 
 // (On UWP we can't check this.)
 #if !HAVE_UWP
-if (!LoadLibrary("d3d11_1sdklayers.dll"))
+if (!LoadLibrary("d3d11_1sdklayers.dll") && is_debug) {
+av_log(ctx, AV_LOG_WARNING, "Failed loading d3d11 debug layers.\n");
 is_debug = 0;
+} else if (is_debug) {
+av_log(ctx, AV_LOG_INFO, "Loaded d3d11 debug layers.\n");
+}
 #endif
 
 if (is_debug)
@@ -689,9 +693,17 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, 
const char *device,
 if (pf_DXGIGetDebugInterface) {
 IDXGIDebug *dxgi_debug = NULL;
 hr = pf_DXGIGetDebugInterface(_IDXGIDebug, 
(void**)_debug);
-if (SUCCEEDED(hr) && dxgi_debug)
+if (SUCCEEDED(hr) && dxgi_debug) {
 IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, 
DXGI_DEBUG_RLO_ALL);
+av_log(ctx, AV_LOG_INFO, "Enabled dxgi debugging.\n");
+} else {
+av_log(ctx, AV_LOG_WARNING, "Failed enabling dxgi 
debugging.\n");
+}
+} else {
+av_log(ctx, AV_LOG_WARNING, "Failed getting dxgi debug 
interface.\n");
 }
+} else {
+av_log(ctx, AV_LOG_WARNING, "Failed loading dxgi debug 
library.\n");
 }
 }
 #endif
-- 
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-03-13 Thread James Almer

On 2/14/2024 10:41 AM, Kieran Kunhya wrote:

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


I'll apply this patch soon (with the addition of forcing the vvc decoder 
and -strict experimental for the tests).

___
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] Change rdiv (vf_convolution) documentation to reflect actual behavior

2024-03-13 Thread Marton Balint



On Wed, 13 Mar 2024, Stone Chen wrote:


On Wed, Mar 13, 2024 at 4:26 AM Marton Balint  wrote:




On Tue, 12 Mar 2024, Stone Chen wrote:

> The documentation correctly states that the rdiv is a multiplier but
incorrectly states the default behavior is to multiply by the sum of all
matrix elements - it multiplies by 1/sum.
>
> This changes the documentation to match the code.

Please mention in the commit message the ticket number this patch fixes.

Thanks,
Marton



Hi Marton,

I just noticed that the ticket was closed
https://trac.ffmpeg.org/ticket/10294 (Michael Koch's comment re: docs).


There is a new ticket for the documentation issue, ticket #10889.

Please mention that in the message.

Thanks,
Marton



Should I open a new ticket?

Cheers
Stone



> ---
> doc/filters.texi | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index e0436a5755..913365671d 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -10497,7 +10497,7 @@ and from 1 to 49 odd number of signed integers
in @var{row} mode.
> @item 2rdiv
> @item 3rdiv
> Set multiplier for calculated value for each plane.
> -If unset or 0, it will be sum of all matrix elements.
> +If unset or 0, it will be 1/sum of all matrix elements.
>
> @item 0bias
> @item 1bias
> --
> 2.44.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 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 mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avutil/hwcontext_d3d11va: prefer DXGI 1.1 factory when available

2024-03-13 Thread Timo Rothenpieler
A lot of modern stuff straight up fails on the old 1.0 factory, which is
masked by the fact that it's only used when an explicit adapter is
specified.
---
 libavutil/hwcontext_d3d11va.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 24b3546e7b..cf793a2f48 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -62,7 +62,9 @@ static av_cold void load_functions(void)
 return;
 
 mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, 
"D3D11CreateDevice");
-mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, 
"CreateDXGIFactory");
+mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, 
"CreateDXGIFactory1");
+if (!mCreateDXGIFactory)
+mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, 
"CreateDXGIFactory");
 #else
 // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
 // only CreateDXGIFactory1
-- 
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 v3 2/2] lavc/vulkan_av1: port to the new stable API

2024-03-13 Thread Lynne
Tested by multiple users on multiple operating systems,
driver implementations and test samples to work.

Co-Authored-by: Dave Airlie 

>From e2d31951f46fcc10e1263b8603e486e111e9578c Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Fri, 19 Jan 2024 10:49:02 +1000
Subject: [PATCH v3 2/2] lavc/vulkan_av1: port to the new stable API

Co-Authored-by: Dave Airlie 
---
 configure |   4 +-
 libavcodec/Makefile   |   5 +-
 libavcodec/av1.h  |   2 +
 libavcodec/vulkan_av1.c   | 502 ++
 libavcodec/vulkan_decode.c|  31 +-
 libavcodec/vulkan_decode.h|   2 +-
 libavcodec/vulkan_video.h |   2 -
 .../vulkan_video_codec_av1std_decode_mesa.h   |  36 --
 libavcodec/vulkan_video_codec_av1std_mesa.h   | 403 --
 libavutil/hwcontext_vulkan.c  |   2 +-
 libavutil/vulkan_functions.h  |   2 +-
 libavutil/vulkan_loader.h |   2 +-
 12 files changed, 300 insertions(+), 693 deletions(-)
 delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode_mesa.h
 delete mode 100644 libavcodec/vulkan_video_codec_av1std_mesa.h

diff --git a/configure b/configure
index 05f8283af9..b07a742a74 100755
--- a/configure
+++ b/configure
@@ -7229,8 +7229,8 @@ enabled vdpau &&
 check_lib vdpau_x11 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau -lX11
 
 if enabled vulkan; then
-check_pkg_config_header_only vulkan "vulkan >= 1.3.255" "vulkan/vulkan.h" "defined VK_VERSION_1_3" ||
-check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 255)"
+check_pkg_config_header_only vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" ||
+check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 277)"
 fi
 
 if disabled vulkan; then
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 708434ac76..c552f034b7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1258,8 +1258,7 @@ SKIPHEADERS+= %_tablegen.h  \
   aacenc_quantization.h \
   aacenc_quantization_misc.h\
   bitstream_template.h  \
-  vulkan_video_codec_av1std_mesa.h \
-  $(ARCH)/vpx_arith.h  \
+  $(ARCH)/vpx_arith.h   \
 
 SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
 SKIPHEADERS-$(CONFIG_D3D11VA)  += d3d11va.h dxva2_internal.h
@@ -1280,7 +1279,7 @@ SKIPHEADERS-$(CONFIG_QSVENC)   += qsvenc.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_mesa.h
+SKIPHEADERS-$(CONFIG_VULKAN)   += vulkan.h vulkan_video.h vulkan_decode.h
 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h
 SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
diff --git a/libavcodec/av1.h b/libavcodec/av1.h
index 8704bc41c1..18d5fa9e7f 100644
--- a/libavcodec/av1.h
+++ b/libavcodec/av1.h
@@ -121,6 +121,8 @@ enum {
 AV1_DIV_LUT_NUM   = 257,
 
 AV1_MAX_LOOP_FILTER = 63,
+
+AV1_RESTORATION_TILESIZE_MAX = 256,
 };
 
 
diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
index 5afd5353cc..dc71ecf1fa 100644
--- a/libavcodec/vulkan_av1.c
+++ b/libavcodec/vulkan_av1.c
@@ -26,7 +26,7 @@
 const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = {
 .codec_id = AV_CODEC_ID_AV1,
 .decode_extension = FF_VK_EXT_VIDEO_DECODE_AV1,
-.decode_op= 0x0100, /* TODO fix this */
+.decode_op= VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR,
 .ext_props = {
 .extensionName = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME,
 .specVersion   = VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION,
@@ -36,22 +36,34 @@ const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = {
 typedef struct AV1VulkanDecodePicture {
 FFVulkanDecodePicture   vp;
 
-/* Workaround for a spec issue.
- *Can be removed once no longer needed, and threading can be enabled. */
+/* TODO: investigate if this can be removed to make decoding completely
+ * independent. */
 FFVulkanDecodeContext  *dec;
 
-StdVideoAV1MESATiletiles[MAX_TILES];
-StdVideoAV1MESATileListtile_list;
-const uint32_t*tile_offsets;
+uint32_t 

[FFmpeg-devel] [PATCH v3 1/2] lavc/cbs_av1: fill in ref_frame_sign_bias and order_hints

2024-03-13 Thread Lynne
Unchanged from v2

>From 426701f4fb00123f2fc46efda188ca7d2413b187 Mon Sep 17 00:00:00 2001
From: Lynne 
Date: Fri, 2 Feb 2024 03:54:06 +0100
Subject: [PATCH v3 1/2] lavc/cbs_av1: fill in ref_frame_sign_bias and
 order_hints

Needed for Vulkan AV1.
---
 libavcodec/cbs_av1.h |  2 ++
 libavcodec/cbs_av1_syntax_template.c | 11 +++
 2 files changed, 13 insertions(+)

diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index a5402f069d..0ed49e03ca 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -465,6 +465,8 @@ typedef struct CodedBitstreamAV1Context {
 int tile_num;
 
 AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
+uint8_t ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME];
+uint8_t order_hints[AV1_TOTAL_REFS_PER_FRAME];
 
 // AVOptions
 int operating_point;
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 3be1f2d30f..20eed7ff9e 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1572,6 +1572,17 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
 }
 
 if (!frame_is_intra) {
+for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
+uint8_t ref_frame = AV1_REF_FRAME_LAST + i;
+if (seq->enable_order_hint) {
+uint8_t hint = current->ref_order_hint[current->ref_frame_idx[i]];
+uint8_t sign_bias = cbs_av1_get_relative_dist(seq, hint, priv->order_hint) > 0;
+priv->order_hints[ref_frame] = hint;
+priv->ref_frame_sign_bias[ref_frame] = sign_bias;
+} else {
+priv->ref_frame_sign_bias[ref_frame] = 0;
+}
+}
 // Derive reference frame sign biases.
 }
 
-- 
2.43.0.381.gb435a96ce8

___
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] Change rdiv (vf_convolution) documentation to reflect actual behavior

2024-03-13 Thread Stone Chen
On Wed, Mar 13, 2024 at 4:26 AM Marton Balint  wrote:

>
>
> On Tue, 12 Mar 2024, Stone Chen wrote:
>
> > The documentation correctly states that the rdiv is a multiplier but
> incorrectly states the default behavior is to multiply by the sum of all
> matrix elements - it multiplies by 1/sum.
> >
> > This changes the documentation to match the code.
>
> Please mention in the commit message the ticket number this patch fixes.
>
> Thanks,
> Marton
>

Hi Marton,

I just noticed that the ticket was closed
https://trac.ffmpeg.org/ticket/10294 (Michael Koch's comment re: docs).

Should I open a new ticket?

Cheers
Stone


> > ---
> > doc/filters.texi | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index e0436a5755..913365671d 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -10497,7 +10497,7 @@ and from 1 to 49 odd number of signed integers
> in @var{row} mode.
> > @item 2rdiv
> > @item 3rdiv
> > Set multiplier for calculated value for each plane.
> > -If unset or 0, it will be sum of all matrix elements.
> > +If unset or 0, it will be 1/sum of all matrix elements.
> >
> > @item 0bias
> > @item 1bias
> > --
> > 2.44.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 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/internal: Remove declaration for ff_format_io_close_default()

2024-03-13 Thread Andreas Rheinhardt
Forgotten in d6799ee0e41dee35ebf9c664173aed8e3ab24141.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/internal.h | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 2e59036a53..e5f8337130 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -719,10 +719,6 @@ int ff_copy_whiteblacklists(AVFormatContext *dst, const 
AVFormatContext *src);
  */
 int ff_format_io_close(AVFormatContext *s, AVIOContext **pb);
 
-/* Default io_close callback, not to be used directly, use ff_format_io_close
- * instead. */
-void ff_format_io_close_default(AVFormatContext *s, AVIOContext *pb);
-
 /**
  * Utility function to check if the file uses http or https protocol
  *
-- 
2.40.1

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

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


[FFmpeg-devel] [PATCH] fate/ffmpeg: add a test for loopback decoding

2024-03-13 Thread James Almer
Signed-off-by: James Almer 
---
 tests/fate/ffmpeg.mak   |  7 +++
 tests/ref/fate/ffmpeg-loopback-decoding | 57 +
 2 files changed, 64 insertions(+)
 create mode 100644 tests/ref/fate/ffmpeg-loopback-decoding

diff --git a/tests/fate/ffmpeg.mak b/tests/fate/ffmpeg.mak
index 669c878c7f..aab9d103e1 100644
--- a/tests/fate/ffmpeg.mak
+++ b/tests/fate/ffmpeg.mak
@@ -254,3 +254,10 @@ fate-ffmpeg-streamcopy-t: CMD = ffmpeg
 -stream_loop -1 -f rawvideo -s 352x288 -pix_fmt yuv420p -i 
$(TARGET_PATH)/tests/data/vsynth_lena.yuv  \
 -c copy -f null -t 1 -
 FATE_FFMPEG-$(call REMUX, RAWVIDEO) += fate-ffmpeg-streamcopy-t
+
+# Test loopback decoding and passing the output to a complex graph.
+fate-ffmpeg-loopback-decoding: tests/data/vsynth_lena.yuv
+fate-ffmpeg-loopback-decoding:  CMD = transcode \
+"rawvideo -s 352x288 -pix_fmt yuv420p" 
$(TARGET_PATH)/tests/data/vsynth_lena.yuv nut \
+"-map 0:v:0 -c:v mpeg2video -f null - -dec 0:0 -filter_complex 
'[0:v][dec:0]hstack[stack]' -map '[stack]' -c:v ffv1" ""
+FATE_FFMPEG-$(call ENCDEC2, MPEG2VIDEO, FFV1, NUT, HSTACK_FILTER PIPE_PROTOCOL 
FRAMECRC_MUXER) += fate-ffmpeg-loopback-decoding
diff --git a/tests/ref/fate/ffmpeg-loopback-decoding 
b/tests/ref/fate/ffmpeg-loopback-decoding
new file mode 100644
index 00..e535b9060f
--- /dev/null
+++ b/tests/ref/fate/ffmpeg-loopback-decoding
@@ -0,0 +1,57 @@
+faefe475118cacc36dff3cab59baa6cf *tests/data/fate/ffmpeg-loopback-decoding.nut
+6478832 tests/data/fate/ffmpeg-loopback-decoding.nut
+#tb 0: 1/25
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 704x288
+#sar 0: 0/1
+0,  0,  0,1,   304128, 0xe07dafdd
+0,  1,  1,1,   304128, 0xc5734e5d
+0,  2,  2,1,   304128, 0x855acdcc
+0,  3,  3,1,   304128, 0x4ad94309
+0,  4,  4,1,   304128, 0x174ebea3
+0,  5,  5,1,   304128, 0xdb416da6
+0,  6,  6,1,   304128, 0x72442b79
+0,  7,  7,1,   304128, 0x00ddf9ed
+0,  8,  8,1,   304128, 0xe7e7a773
+0,  9,  9,1,   304128, 0x7df26501
+0, 10, 10,1,   304128, 0x4f5a3eb3
+0, 11, 11,1,   304128, 0x1ad35b6c
+0, 12, 12,1,   304128, 0xec8e6f56
+0, 13, 13,1,   304128, 0xb237e0ef
+0, 14, 14,1,   304128, 0x55b26ce2
+0, 15, 15,1,   304128, 0x22920436
+0, 16, 16,1,   304128, 0x54eea0c0
+0, 17, 17,1,   304128, 0x17113686
+0, 18, 18,1,   304128, 0xeb9ae1af
+0, 19, 19,1,   304128, 0x1ba09d4c
+0, 20, 20,1,   304128, 0x0100748f
+0, 21, 21,1,   304128, 0xcc914570
+0, 22, 22,1,   304128, 0x9bc21952
+0, 23, 23,1,   304128, 0xc118d0af
+0, 24, 24,1,   304128, 0x7e4b2df0
+0, 25, 25,1,   304128, 0x1078bff2
+0, 26, 26,1,   304128, 0xeedbeda1
+0, 27, 27,1,   304128, 0x35ac0a1b
+0, 28, 28,1,   304128, 0x3644fb76
+0, 29, 29,1,   304128, 0x5efa175c
+0, 30, 30,1,   304128, 0x72c14f39
+0, 31, 31,1,   304128, 0xd7c46bb0
+0, 32, 32,1,   304128, 0x20f368ab
+0, 33, 33,1,   304128, 0x9bea7ced
+0, 34, 34,1,   304128, 0xf1b66b94
+0, 35, 35,1,   304128, 0x3e5e6815
+0, 36, 36,1,   304128, 0x6c2d5e3a
+0, 37, 37,1,   304128, 0x763046b0
+0, 38, 38,1,   304128, 0x05f71f4c
+0, 39, 39,1,   304128, 0x3db72dff
+0, 40, 40,1,   304128, 0x86e34c11
+0, 41, 41,1,   304128, 0x09334889
+0, 42, 42,1,   304128, 0xc8566851
+0, 43, 43,1,   304128, 0x4a7ec9da
+0, 44, 44,1,   304128, 0x609a176b
+0, 45, 45,1,   304128, 0x98deede0
+0, 46, 46,1,   304128, 0x59ee66a3
+0, 47, 47,1,   304128, 0x0fc5c8c2
+0, 48, 48,1,   304128, 0x0371d7b0
+0, 49, 49,1,   304128, 0xd81c18cf
-- 
2.44.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 v4] avcodec/libx264: fix extradata when config annexb=0

2024-03-13 Thread Zhao Zhili



> On Mar 12, 2024, at 23:00, Andreas Rheinhardt 
>  wrote:
> 
> Zhao Zhili:
>> From: Zhao Zhili 
>> 
>> ---
>> v4: Fix missing SEI in set_avcc_extradata
>> v3: Remove unnecessary inclusion
>> 
>> configure|   2 +-
>> libavcodec/libx264.c | 153 ---
>> 2 files changed, 130 insertions(+), 25 deletions(-)
>> 
>> diff --git a/configure b/configure
>> index db7dc89755..24cb897d28 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3491,7 +3491,7 @@ libwebp_encoder_deps="libwebp"
>> libwebp_anim_encoder_deps="libwebp"
>> libx262_encoder_deps="libx262"
>> libx264_encoder_deps="libx264"
>> -libx264_encoder_select="atsc_a53"
>> +libx264_encoder_select="atsc_a53 h264parse"
>> libx264rgb_encoder_deps="libx264"
>> libx264rgb_encoder_select="libx264_encoder"
>> libx265_encoder_deps="libx265"
>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
>> index 10d646bd76..e7d16997d2 100644
>> --- a/libavcodec/libx264.c
>> +++ b/libavcodec/libx264.c
>> @@ -34,6 +34,7 @@
>> #include "avcodec.h"
>> #include "codec_internal.h"
>> #include "encode.h"
>> +#include "h264_ps.h"
>> #include "internal.h"
>> #include "packet_internal.h"
>> #include "atsc_a53.h"
>> @@ -865,6 +866,131 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
>> return 0;
>> }
>> 
>> +static int save_sei(AVCodecContext *avctx, x264_nal_t *nal)
>> +{
>> +X264Context *x4 = avctx->priv_data;
>> +
>> +av_log(avctx, AV_LOG_INFO, "%s\n", nal->p_payload + 25);
>> +x4->sei_size = nal->i_payload;
>> +x4->sei = av_malloc(x4->sei_size);
>> +if (!x4->sei)
>> +return AVERROR(ENOMEM);
>> +
>> +memcpy(x4->sei, nal->p_payload, nal->i_payload);
>> +
>> +return 0;
>> +}
>> +
>> +static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int 
>> nnal)
>> +{
>> +X264Context *x4 = avctx->priv_data;
>> +x264_nal_t *sps_nal = NULL;
>> +x264_nal_t *pps_nal = NULL;
>> +uint8_t *p, *sps;
>> +int ret;
>> +
>> +/* We know it's in the order of SPS/PPS/SEI, but it's not documented in 
>> x264 API.
>> + * The x264 param i_sps_id implies there is a single pair of SPS/PPS.
>> + */
>> +for (int i = 0; i < nnal; i++) {
>> +switch (nal[i].i_type) {
>> +case NAL_SPS:
>> +sps_nal = [i];
>> +break;
>> +case NAL_PPS:
>> +pps_nal = [i];
>> +break;
>> +case NAL_SEI:
>> +ret = save_sei(avctx, [i]);
>> +if (ret < 0)
>> +return ret;
>> +break;
>> +}
>> +}
>> +if (!sps_nal || !pps_nal)
>> +return AVERROR_EXTERNAL;
>> +
>> +avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 7;
>> +avctx->extradata = av_mallocz(avctx->extradata_size + 
>> AV_INPUT_BUFFER_PADDING_SIZE);
>> +if (!avctx->extradata)
>> +return AVERROR(ENOMEM);
>> +
>> +// Now create AVCDecoderConfigurationRecord
>> +p = avctx->extradata;
>> +// Skip size part
>> +sps = sps_nal->p_payload + 4;
>> +*p++ = 1; // version
>> +*p++ = sps[1]; // AVCProfileIndication
>> +*p++ = sps[2]; // profile_compatibility
>> +*p++ = sps[3]; // AVCLevelIndication
>> +*p++ = 0xFF;
>> +*p++ = 0xE0 | 0x01; // 3 bits reserved (111) + 5 bits number of sps
>> +memcpy(p, sps_nal->p_payload + 2, sps_nal->i_payload - 2);
>> +// Make sps has AV_INPUT_BUFFER_PADDING_SIZE padding, so it can be used
>> +// with GetBitContext
>> +sps = p + 2;
>> +p += sps_nal->i_payload - 2;
>> +*p++ = 1;
>> +memcpy(p, pps_nal->p_payload + 2, pps_nal->i_payload - 2);
>> +p += pps_nal->i_payload - 2;
>> +
>> +if (sps[3] != 66 && sps[3] != 77 && sps[3] != 88) {
>> +GetBitContext gbc;
>> +H264ParamSets ps = { 0 };
>> +
>> +init_get_bits8(, sps, sps_nal->i_payload - 4);
>> +skip_bits(, 8);
>> +ret = ff_h264_decode_seq_parameter_set(, avctx, , 1);
> 
> ff_h264_decode_seq_parameter_set() expects to read from a GetBitContext
> whose buffer has already been stripped of 0x03 escape bytes. Your buffer
> hasn't and therefore it is possible for this function to return an error
> even when the input is fine.

Good point. Here is v5
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-March/323386.html

> 
>> +if (ret < 0)
>> +return ret;
>> +
>> +ps.sps = ps.sps_list[x4->params.i_sps_id];
>> +*p++ = 0xFC | ps.sps->chroma_format_idc;
>> +*p++ = 0xF8 | (ps.sps->bit_depth_luma - 8);
>> +*p++ = 0xF8 | (ps.sps->bit_depth_chroma - 8);
>> +*p++ = 0;
>> +ff_h264_ps_uninit();
>> +}
>> +av_assert0(avctx->extradata + avctx->extradata_size >= p);
>> +avctx->extradata_size = p - avctx->extradata;
>> +
>> +return 0;
>> +}
>> +
>> +static int set_extradata(AVCodecContext *avctx)
>> +{
>> +X264Context *x4 = avctx->priv_data;
>> +x264_nal_t *nal;
>> +uint8_t *p;
>> +int nnal, s;
>> 

[FFmpeg-devel] [PATCH v5] avcodec/libx264: fix extradata when config annexb=0

2024-03-13 Thread Zhao Zhili
From: Zhao Zhili 

---
v5: Decode chroma_format_idc directly instead of 
ff_h264_decode_seq_parameter_set
v4: Fix missing SEI in set_avcc_extradata
v3: Remove unnecessary inclusion

 libavcodec/libx264.c | 162 ---
 1 file changed, 138 insertions(+), 24 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 10d646bd76..64cefb5fb0 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -38,6 +38,7 @@
 #include "packet_internal.h"
 #include "atsc_a53.h"
 #include "sei.h"
+#include "golomb.h"
 
 #include 
 #include 
@@ -865,6 +866,140 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
 return 0;
 }
 
+static int save_sei(AVCodecContext *avctx, x264_nal_t *nal)
+{
+X264Context *x4 = avctx->priv_data;
+
+av_log(avctx, AV_LOG_INFO, "%s\n", nal->p_payload + 25);
+x4->sei_size = nal->i_payload;
+x4->sei = av_malloc(x4->sei_size);
+if (!x4->sei)
+return AVERROR(ENOMEM);
+
+memcpy(x4->sei, nal->p_payload, nal->i_payload);
+
+return 0;
+}
+
+static int set_avcc_extradata(AVCodecContext *avctx, x264_nal_t *nal, int nnal)
+{
+X264Context *x4 = avctx->priv_data;
+x264_nal_t *sps_nal = NULL;
+x264_nal_t *pps_nal = NULL;
+uint8_t *p, *sps;
+int ret;
+
+/* We know it's in the order of SPS/PPS/SEI, but it's not documented in 
x264 API.
+ * The x264 param i_sps_id implies there is a single pair of SPS/PPS.
+ */
+for (int i = 0; i < nnal; i++) {
+switch (nal[i].i_type) {
+case NAL_SPS:
+sps_nal = [i];
+break;
+case NAL_PPS:
+pps_nal = [i];
+break;
+case NAL_SEI:
+ret = save_sei(avctx, [i]);
+if (ret < 0)
+return ret;
+break;
+}
+}
+if (!sps_nal || !pps_nal)
+return AVERROR_EXTERNAL;
+
+avctx->extradata_size = sps_nal->i_payload + pps_nal->i_payload + 7;
+avctx->extradata = av_mallocz(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!avctx->extradata)
+return AVERROR(ENOMEM);
+
+// Now create AVCDecoderConfigurationRecord
+p = avctx->extradata;
+// Skip size part
+sps = sps_nal->p_payload + 4;
+*p++ = 1; // version
+*p++ = sps[1]; // AVCProfileIndication
+*p++ = sps[2]; // profile_compatibility
+*p++ = sps[3]; // AVCLevelIndication
+*p++ = 0xFF;
+*p++ = 0xE0 | 0x01; // 3 bits reserved (111) + 5 bits number of sps
+memcpy(p, sps_nal->p_payload + 2, sps_nal->i_payload - 2);
+// Make sps has AV_INPUT_BUFFER_PADDING_SIZE padding, so it can be used
+// with GetBitContext
+sps = p + 2;
+p += sps_nal->i_payload - 2;
+*p++ = 1;
+memcpy(p, pps_nal->p_payload + 2, pps_nal->i_payload - 2);
+p += pps_nal->i_payload - 2;
+
+if (sps[3] != 66 && sps[3] != 77 && sps[3] != 88) {
+GetBitContext gbc;
+int chroma_format_idc;
+int bit_depth_luma_minus8, bit_depth_chroma_minus8;
+
+/* It's not possible to have emulation prevention byte before
+ * bit_depth_chroma_minus8 due to the range of sps id, 
chroma_format_idc
+ * and so on. So we can read directly without need to escape emulation
+ * prevention byte.
+ *
+ * +4 to skip until sps id.
+ */
+init_get_bits8(, sps + 4, sps_nal->i_payload - 4 - 4);
+// Skip sps id
+get_ue_golomb_31();
+chroma_format_idc = get_ue_golomb_31();
+if (chroma_format_idc == 3)
+skip_bits1();
+bit_depth_luma_minus8 = get_ue_golomb_31();
+bit_depth_chroma_minus8 = get_ue_golomb_31();
+
+*p++ = 0xFC | chroma_format_idc;
+*p++ = 0xF8 | bit_depth_luma_minus8;
+*p++ = 0xF8 | bit_depth_chroma_minus8;
+*p++ = 0;
+}
+av_assert0(avctx->extradata + avctx->extradata_size >= p);
+avctx->extradata_size = p - avctx->extradata;
+
+return 0;
+}
+
+static int set_extradata(AVCodecContext *avctx)
+{
+X264Context *x4 = avctx->priv_data;
+x264_nal_t *nal;
+uint8_t *p;
+int nnal, s;
+
+s = x264_encoder_headers(x4->enc, , );
+if (s < 0)
+return AVERROR_EXTERNAL;
+
+if (!x4->params.b_annexb)
+return set_avcc_extradata(avctx, nal, nnal);
+
+avctx->extradata = p = av_mallocz(s + AV_INPUT_BUFFER_PADDING_SIZE);
+if (!p)
+return AVERROR(ENOMEM);
+
+for (int i = 0; i < nnal; i++) {
+/* Don't put the SEI in extradata. */
+if (nal[i].i_type == NAL_SEI) {
+s = save_sei(avctx, [i]);
+if (s < 0)
+return s;
+continue;
+}
+memcpy(p, nal[i].p_payload, nal[i].i_payload);
+p += nal[i].i_payload;
+}
+avctx->extradata_size = p - avctx->extradata;
+
+return 0;
+}
+
 #define PARSE_X264_OPT(name, var)\
 if (x4->var && x264_param_parse(>params, name, x4->var) < 0) {\
 av_log(avctx, 

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Gyan Doshi




On 2024-03-13 05:54 pm, Niklas Haas wrote:

From: Niklas Haas

This filter's existing design has a number of issues:

- There is no guarantee whatsoever about the order in which frames are
   pushed onto the main and ref link, due to this being entirely
   dependent on the order in which downstream filters decide to request
   frames from their various inputs. As such, there is absolutely no
   synchronization for ref streams with dynamically changing resolutions
   (see e.g. fate/h264/reinit-*).


The only raison d'etre for scale2ref was to have some way to access 
another stream's parameters. Dynamic streams weren't really the focus.



- For some (likely historical) reason, this filter outputs its ref
   stream as a second ref output, which is in principle completely
   unnecessary (complex filter graph users can just duplicate the input
   pin), but in practice only required to allow this filter to
   "eventually" see changes to the ref stream (see first point). In
   particular, this means that if the user uses the "wrong" pin, this
   filter may break completely.


This change is fine but you should note in the manual docs that this 
change has occurred (and when) as existing scripts will fail due to the 
surplus output pad.


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

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


Re: [FFmpeg-devel] [PATCH 1/2] avfilter: mark scale2ref as supporting dynamic sizes

2024-03-13 Thread Gyan Doshi




On 2024-03-13 05:54 pm, Niklas Haas wrote:

From: Niklas Haas 

Analogous to the "scale" filter, which this is practically identical
with.
---
  libavfilter/avfilter.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 831871de90b..dcad4d55292 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1027,7 +1027,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
  strcmp(link->dst->filter->name, "format") &&
  strcmp(link->dst->filter->name, "idet") &&
  strcmp(link->dst->filter->name, "null") &&
-strcmp(link->dst->filter->name, "scale")) {
+strcmp(link->dst->filter->name, "scale") &&
+strcmp(link->dst->filter->name, "scale2ref")) {
  av_assert1(frame->format== link->format);
  av_assert1(frame->width == link->w);
  av_assert1(frame->height== link->h);


LGTM.

Regards,
Gyan

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

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


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Niklas Haas
On Wed, 13 Mar 2024 13:24:25 +0100 Niklas Haas  wrote:
> -frame_changed = in->width  != link->w ||
> -in->height != link->h ||
> -in->format != link->format ||
> -in->sample_aspect_ratio.den != 
> link->sample_aspect_ratio.den ||
> -in->sample_aspect_ratio.num != 
> link->sample_aspect_ratio.num ||
> -in->colorspace != link->colorspace ||
> -in->color_range != link->color_range;
> +ret = ff_framesync_dualinput_get(fs, , );
> +if (ret < 0)
> +return ret;
>  
> -if (frame_changed) {
> -link->format = in->format;
> -link->w = in->width;
> -link->h = in->height;
> -link->sample_aspect_ratio.num = in->sample_aspect_ratio.num;
> -link->sample_aspect_ratio.den = in->sample_aspect_ratio.den;
> -link->colorspace = in->colorspace;
> -link->color_range = in->color_range;
> +if (ref) {
> +reflink->format = ref->format;
> +reflink->w = ref->width;
> +reflink->h = ref->height;
> +reflink->sample_aspect_ratio.num = ref->sample_aspect_ratio.num;
> +reflink->sample_aspect_ratio.den = ref->sample_aspect_ratio.den;
> +reflink->colorspace = ref->colorspace;
> +reflink->color_range = ref->color_range;
>  
> -config_props_ref(outlink);
> -}
> +ret = config_props(outlink);
> +if (ret < 0)
> +return ret;

This change unintentionally dropped the `frame_changed` check to avoid
reconfiguring the sws context unnecessarily. Fixed locally by
reintroducing the check.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 2/2] avfilter/vf_scale2ref: switch to FFFrameSync

2024-03-13 Thread Niklas Haas
From: Niklas Haas 

This filter's existing design has a number of issues:

- There is no guarantee whatsoever about the order in which frames are
  pushed onto the main and ref link, due to this being entirely
  dependent on the order in which downstream filters decide to request
  frames from their various inputs. As such, there is absolutely no
  synchronization for ref streams with dynamically changing resolutions
  (see e.g. fate/h264/reinit-*).

- For some (likely historical) reason, this filter outputs its ref
  stream as a second ref output, which is in principle completely
  unnecessary (complex filter graph users can just duplicate the input
  pin), but in practice only required to allow this filter to
  "eventually" see changes to the ref stream (see first point). In
  particular, this means that if the user uses the "wrong" pin, this
  filter may break completely.

- The default filter activation function is fundamentally incapable of
  handling filters with multiple inputs cleanly, because doing so
  requires both knowledge of how these inputs should be internally
  ordered, but also how to handle EOF conditions on either input (or
  downstream). Both of these are best left to the filter specific
  options. (See #10795 for the consequences of using the default
  activate with multiple inputs).

Switching this filter to framesync fixes all three points:

- ff_framesync_activate() correctly handles multiple inputs and EOF
  conditions (and is configurable with the framesync-specific options)
- framesync only supports a single output, so we can (indeed must) drop
  the redundant ref output stream

Update documentation, changelog and tests to correspond to the new usage
pattern.

Fixes: https://trac.ffmpeg.org/ticket/10795
---
 Changelog|   2 +
 doc/filters.texi |  10 +-
 libavfilter/vf_scale.c   | 130 ---
 tests/filtergraphs/scale2ref_keep_aspect |   3 +-
 4 files changed, 76 insertions(+), 69 deletions(-)

diff --git a/Changelog b/Changelog
index 069b8274489..bacda2524ea 100644
--- a/Changelog
+++ b/Changelog
@@ -32,6 +32,8 @@ version :
 - DVD-Video demuxer, powered by libdvdnav and libdvdread
 - ffprobe -show_stream_groups option
 - ffprobe (with -export_side_data film_grain) now prints film grain metadata
+- scale2ref now only has a single output stream, and supports the framesync
+  options
 
 
 version 6.1:
diff --git a/doc/filters.texi b/doc/filters.texi
index e0436a5755c..07e8136adb3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21555,9 +21555,9 @@ Deprecated, do not use.
 Scale (resize) the input video, based on a reference video.
 
 See the scale filter for available options, scale2ref supports the same but
-uses the reference video instead of the main input as basis. scale2ref also
-supports the following additional constants for the @option{w} and
-@option{h} options:
+uses the reference video instead of the main input as basis. This filter also
+supports the @ref{framesync} options. In addition, scale2ref also supports the
+following additional constants for the @option{w} and @option{h} options:
 
 @table @var
 @item main_w
@@ -21600,13 +21600,13 @@ Only available with @code{eval=frame}.
 @item
 Scale a subtitle stream (b) to match the main video (a) in size before 
overlaying
 @example
-'scale2ref[b][a];[a][b]overlay'
+'[b][a]scale2ref[sub];[a][sub]overlay'
 @end example
 
 @item
 Scale a logo to 1/10th the height of a video, while preserving its display 
aspect ratio.
 @example
-[logo-in][video-in]scale2ref=w=oh*mdar:h=ih/10[logo-out][video-out]
+[logo-in][video]scale2ref=w=oh*mdar:h=ih/10[logo-out]
 @end example
 @end itemize
 
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index fc3b5a91e60..d4173b63097 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -29,6 +29,7 @@
 
 #include "avfilter.h"
 #include "formats.h"
+#include "framesync.h"
 #include "internal.h"
 #include "scale_eval.h"
 #include "video.h"
@@ -114,6 +115,7 @@ typedef struct ScaleContext {
 struct SwsContext *isws[2]; ///< software scaler context for interlaced 
material
 // context used for forwarding options to sws
 struct SwsContext *sws_opts;
+FFFrameSync fs; ///< for scale2ref
 
 /**
  * New dimensions. Special values are:
@@ -288,6 +290,9 @@ static av_cold int preinit(AVFilterContext *ctx)
 if (ret < 0)
 return ret;
 
+if (ctx->filter == _vf_scale2ref)
+ff_framesync_preinit(>fs);
+
 return 0;
 }
 
@@ -303,6 +308,8 @@ static const int sws_colorspaces[] = {
 -1
 };
 
+static int do_scale2ref(FFFrameSync *fs);
+
 static av_cold int init(AVFilterContext *ctx)
 {
 ScaleContext *scale = ctx->priv;
@@ -380,6 +387,7 @@ static av_cold int init(AVFilterContext *ctx)
 if (!threads)
 av_opt_set_int(scale->sws_opts, "threads", 
ff_filter_get_nb_threads(ctx), 0);
 
+scale->fs.on_event = do_scale2ref;
 return 0;
 }

[FFmpeg-devel] [PATCH 1/2] avfilter: mark scale2ref as supporting dynamic sizes

2024-03-13 Thread Niklas Haas
From: Niklas Haas 

Analogous to the "scale" filter, which this is practically identical
with.
---
 libavfilter/avfilter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 831871de90b..dcad4d55292 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -1027,7 +1027,8 @@ int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
 strcmp(link->dst->filter->name, "format") &&
 strcmp(link->dst->filter->name, "idet") &&
 strcmp(link->dst->filter->name, "null") &&
-strcmp(link->dst->filter->name, "scale")) {
+strcmp(link->dst->filter->name, "scale") &&
+strcmp(link->dst->filter->name, "scale2ref")) {
 av_assert1(frame->format== link->format);
 av_assert1(frame->width == link->w);
 av_assert1(frame->height== link->h);
-- 
2.44.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 v2] avcodec/ppc/h264dsp: Fix unaligned stores

2024-03-13 Thread Andreas Rheinhardt
James Almer:
> On 3/13/2024 8:30 AM, Andreas Rheinhardt wrote:
>> Also fix an effective-type violation.
>> Exposed by
>> https://fate.ffmpeg.org/report.cgi?time=20240312011016=ppc-linux-gcc-13.2-ubsan-altivec-qemu
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>   libavcodec/ppc/h264dsp.c | 35 +--
>>   1 file changed, 17 insertions(+), 18 deletions(-)
>>
>> diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
>> index c02733dda2..f50f2553a2 100644
>> --- a/libavcodec/ppc/h264dsp.c
>> +++ b/libavcodec/ppc/h264dsp.c
>> @@ -401,30 +401,29 @@ static inline void write16x4(uint8_t *dst, int
>> dst_stride,
>>    register vec_u8 r0, register vec_u8 r1,
>>    register vec_u8 r2, register vec_u8 r3) {
>>   DECLARE_ALIGNED(16, unsigned char, result)[64];
>> -    uint32_t *src_int = (uint32_t *)result, *dst_int = (uint32_t *)dst;
>> -    int int_dst_stride = dst_stride/4;
>> +    uint32_t *src_int = (uint32_t *)result;
>>     vec_st(r0, 0, result);
>>   vec_st(r1, 16, result);
>>   vec_st(r2, 32, result);
>>   vec_st(r3, 48, result);
>>   /* FIXME: there has to be a better way */
>> -    *dst_int = *src_int;
>> -    *(dst_int+   int_dst_stride) = *(src_int + 1);
>> -    *(dst_int+ 2*int_dst_stride) = *(src_int + 2);
>> -    *(dst_int+ 3*int_dst_stride) = *(src_int + 3);
>> -    *(dst_int+ 4*int_dst_stride) = *(src_int + 4);
>> -    *(dst_int+ 5*int_dst_stride) = *(src_int + 5);
>> -    *(dst_int+ 6*int_dst_stride) = *(src_int + 6);
>> -    *(dst_int+ 7*int_dst_stride) = *(src_int + 7);
>> -    *(dst_int+ 8*int_dst_stride) = *(src_int + 8);
>> -    *(dst_int+ 9*int_dst_stride) = *(src_int + 9);
>> -    *(dst_int+10*int_dst_stride) = *(src_int + 10);
>> -    *(dst_int+11*int_dst_stride) = *(src_int + 11);
>> -    *(dst_int+12*int_dst_stride) = *(src_int + 12);
>> -    *(dst_int+13*int_dst_stride) = *(src_int + 13);
>> -    *(dst_int+14*int_dst_stride) = *(src_int + 14);
>> -    *(dst_int+15*int_dst_stride) = *(src_int + 15);
>> +    AV_WN32(dst,   AV_RN32A(src_int + 0));
>> +    AV_WN32(dst +  dst_stride, AV_RN32A(src_int + 1));
>> +    AV_WN32(dst +  2 * dst_stride, AV_RN32A(src_int + 2));
>> +    AV_WN32(dst +  3 * dst_stride, AV_RN32A(src_int + 3));
>> +    AV_WN32(dst +  4 * dst_stride, AV_RN32A(src_int + 4));
>> +    AV_WN32(dst +  5 * dst_stride, AV_RN32A(src_int + 5));
>> +    AV_WN32(dst +  6 * dst_stride, AV_RN32A(src_int + 6));
>> +    AV_WN32(dst +  7 * dst_stride, AV_RN32A(src_int + 7));
>> +    AV_WN32(dst +  8 * dst_stride, AV_RN32A(src_int + 8));
>> +    AV_WN32(dst +  9 * dst_stride, AV_RN32A(src_int + 9));
>> +    AV_WN32(dst + 10 * dst_stride, AV_RN32A(src_int + 10));
>> +    AV_WN32(dst + 11 * dst_stride, AV_RN32A(src_int + 11));
>> +    AV_WN32(dst + 12 * dst_stride, AV_RN32A(src_int + 12));
>> +    AV_WN32(dst + 13 * dst_stride, AV_RN32A(src_int + 13));
>> +    AV_WN32(dst + 14 * dst_stride, AV_RN32A(src_int + 14));
>> +    AV_WN32(dst + 15 * dst_stride, AV_RN32A(src_int + 15));
> 
> Is there any benefit using AV_RN32A() when src_int is already a pointer
> to a uint32_t?
> 

Simply reading via src_int[idx] would be a violation of the
effective-type rules (you would read from an array of unsigned char via
an lvalue of type uint32_t).
Alternatively, one could use a union of DECLARE_ALIGNED(16, unsigned
char, result)[64] and uint32_t[16], the former to store these vectors,
the latter to read the values from.

- 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 v2] avcodec/ppc/h264dsp: Fix unaligned stores

2024-03-13 Thread James Almer

On 3/13/2024 8:30 AM, Andreas Rheinhardt wrote:

Also fix an effective-type violation.
Exposed by 
https://fate.ffmpeg.org/report.cgi?time=20240312011016=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/ppc/h264dsp.c | 35 +--
  1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
index c02733dda2..f50f2553a2 100644
--- a/libavcodec/ppc/h264dsp.c
+++ b/libavcodec/ppc/h264dsp.c
@@ -401,30 +401,29 @@ static inline void write16x4(uint8_t *dst, int dst_stride,
   register vec_u8 r0, register vec_u8 r1,
   register vec_u8 r2, register vec_u8 r3) {
  DECLARE_ALIGNED(16, unsigned char, result)[64];
-uint32_t *src_int = (uint32_t *)result, *dst_int = (uint32_t *)dst;
-int int_dst_stride = dst_stride/4;
+uint32_t *src_int = (uint32_t *)result;
  
  vec_st(r0, 0, result);

  vec_st(r1, 16, result);
  vec_st(r2, 32, result);
  vec_st(r3, 48, result);
  /* FIXME: there has to be a better way */
-*dst_int = *src_int;
-*(dst_int+   int_dst_stride) = *(src_int + 1);
-*(dst_int+ 2*int_dst_stride) = *(src_int + 2);
-*(dst_int+ 3*int_dst_stride) = *(src_int + 3);
-*(dst_int+ 4*int_dst_stride) = *(src_int + 4);
-*(dst_int+ 5*int_dst_stride) = *(src_int + 5);
-*(dst_int+ 6*int_dst_stride) = *(src_int + 6);
-*(dst_int+ 7*int_dst_stride) = *(src_int + 7);
-*(dst_int+ 8*int_dst_stride) = *(src_int + 8);
-*(dst_int+ 9*int_dst_stride) = *(src_int + 9);
-*(dst_int+10*int_dst_stride) = *(src_int + 10);
-*(dst_int+11*int_dst_stride) = *(src_int + 11);
-*(dst_int+12*int_dst_stride) = *(src_int + 12);
-*(dst_int+13*int_dst_stride) = *(src_int + 13);
-*(dst_int+14*int_dst_stride) = *(src_int + 14);
-*(dst_int+15*int_dst_stride) = *(src_int + 15);
+AV_WN32(dst,   AV_RN32A(src_int + 0));
+AV_WN32(dst +  dst_stride, AV_RN32A(src_int + 1));
+AV_WN32(dst +  2 * dst_stride, AV_RN32A(src_int + 2));
+AV_WN32(dst +  3 * dst_stride, AV_RN32A(src_int + 3));
+AV_WN32(dst +  4 * dst_stride, AV_RN32A(src_int + 4));
+AV_WN32(dst +  5 * dst_stride, AV_RN32A(src_int + 5));
+AV_WN32(dst +  6 * dst_stride, AV_RN32A(src_int + 6));
+AV_WN32(dst +  7 * dst_stride, AV_RN32A(src_int + 7));
+AV_WN32(dst +  8 * dst_stride, AV_RN32A(src_int + 8));
+AV_WN32(dst +  9 * dst_stride, AV_RN32A(src_int + 9));
+AV_WN32(dst + 10 * dst_stride, AV_RN32A(src_int + 10));
+AV_WN32(dst + 11 * dst_stride, AV_RN32A(src_int + 11));
+AV_WN32(dst + 12 * dst_stride, AV_RN32A(src_int + 12));
+AV_WN32(dst + 13 * dst_stride, AV_RN32A(src_int + 13));
+AV_WN32(dst + 14 * dst_stride, AV_RN32A(src_int + 14));
+AV_WN32(dst + 15 * dst_stride, AV_RN32A(src_int + 15));


Is there any benefit using AV_RN32A() when src_int is already a pointer 
to a uint32_t?



  }
  
  /** @brief performs a 6x16 transpose of data in src, and stores it to dst

___
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] avcodec/ppc/h264dsp: Fix unaligned stores

2024-03-13 Thread Andreas Rheinhardt
Also fix an effective-type violation.
Exposed by 
https://fate.ffmpeg.org/report.cgi?time=20240312011016=ppc-linux-gcc-13.2-ubsan-altivec-qemu

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ppc/h264dsp.c | 35 +--
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/libavcodec/ppc/h264dsp.c b/libavcodec/ppc/h264dsp.c
index c02733dda2..f50f2553a2 100644
--- a/libavcodec/ppc/h264dsp.c
+++ b/libavcodec/ppc/h264dsp.c
@@ -401,30 +401,29 @@ static inline void write16x4(uint8_t *dst, int dst_stride,
  register vec_u8 r0, register vec_u8 r1,
  register vec_u8 r2, register vec_u8 r3) {
 DECLARE_ALIGNED(16, unsigned char, result)[64];
-uint32_t *src_int = (uint32_t *)result, *dst_int = (uint32_t *)dst;
-int int_dst_stride = dst_stride/4;
+uint32_t *src_int = (uint32_t *)result;
 
 vec_st(r0, 0, result);
 vec_st(r1, 16, result);
 vec_st(r2, 32, result);
 vec_st(r3, 48, result);
 /* FIXME: there has to be a better way */
-*dst_int = *src_int;
-*(dst_int+   int_dst_stride) = *(src_int + 1);
-*(dst_int+ 2*int_dst_stride) = *(src_int + 2);
-*(dst_int+ 3*int_dst_stride) = *(src_int + 3);
-*(dst_int+ 4*int_dst_stride) = *(src_int + 4);
-*(dst_int+ 5*int_dst_stride) = *(src_int + 5);
-*(dst_int+ 6*int_dst_stride) = *(src_int + 6);
-*(dst_int+ 7*int_dst_stride) = *(src_int + 7);
-*(dst_int+ 8*int_dst_stride) = *(src_int + 8);
-*(dst_int+ 9*int_dst_stride) = *(src_int + 9);
-*(dst_int+10*int_dst_stride) = *(src_int + 10);
-*(dst_int+11*int_dst_stride) = *(src_int + 11);
-*(dst_int+12*int_dst_stride) = *(src_int + 12);
-*(dst_int+13*int_dst_stride) = *(src_int + 13);
-*(dst_int+14*int_dst_stride) = *(src_int + 14);
-*(dst_int+15*int_dst_stride) = *(src_int + 15);
+AV_WN32(dst,   AV_RN32A(src_int + 0));
+AV_WN32(dst +  dst_stride, AV_RN32A(src_int + 1));
+AV_WN32(dst +  2 * dst_stride, AV_RN32A(src_int + 2));
+AV_WN32(dst +  3 * dst_stride, AV_RN32A(src_int + 3));
+AV_WN32(dst +  4 * dst_stride, AV_RN32A(src_int + 4));
+AV_WN32(dst +  5 * dst_stride, AV_RN32A(src_int + 5));
+AV_WN32(dst +  6 * dst_stride, AV_RN32A(src_int + 6));
+AV_WN32(dst +  7 * dst_stride, AV_RN32A(src_int + 7));
+AV_WN32(dst +  8 * dst_stride, AV_RN32A(src_int + 8));
+AV_WN32(dst +  9 * dst_stride, AV_RN32A(src_int + 9));
+AV_WN32(dst + 10 * dst_stride, AV_RN32A(src_int + 10));
+AV_WN32(dst + 11 * dst_stride, AV_RN32A(src_int + 11));
+AV_WN32(dst + 12 * dst_stride, AV_RN32A(src_int + 12));
+AV_WN32(dst + 13 * dst_stride, AV_RN32A(src_int + 13));
+AV_WN32(dst + 14 * dst_stride, AV_RN32A(src_int + 14));
+AV_WN32(dst + 15 * dst_stride, AV_RN32A(src_int + 15));
 }
 
 /** @brief performs a 6x16 transpose of data in src, and stores it to dst
-- 
2.40.1

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

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


Re: [FFmpeg-devel] [PATCH] lavfi/atempo: avoid asendcmd assertion failure

2024-03-13 Thread Rajiv Harlalka

On 3/13/24 8:39 AM, Pavel Koshevoy wrote:

On Tue, Mar 12, 2024 at 9:01 PM Pavel Koshevoy  wrote:


From: Rajiv Harlalka 

Check for zeros equal to the total samples early, because in
that case we would already be leaving the first few frames out.

Fixes trac ticket #10692
---
  libavfilter/af_atempo.c | 18 +-
  1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c
index 4621b67b03..654b080e89 100644
--- a/libavfilter/af_atempo.c
+++ b/libavfilter/af_atempo.c
@@ -531,21 +531,21 @@ static int yae_load_frag(ATempoContext *atempo,
  dst = frag->data;

  start = atempo->position[0] - atempo->size;
-zeros = 0;

-if (frag->position[0] < start) {
-// what we don't have we substitute with zeros:
-zeros = FFMIN(start - frag->position[0], (int64_t)nsamples);
-av_assert0(zeros != nsamples);
-
-memset(dst, 0, zeros * atempo->stride);
-dst += zeros * atempo->stride;
-}
+// what we don't have we substitute with zeros:
+zeros =
+  frag->position[0] < start ?
+  FFMIN(start - frag->position[0], (int64_t)nsamples) : 0;

  if (zeros == nsamples) {
  return 0;
  }

+if (frag->position[0] < start) {
+memset(dst, 0, zeros * atempo->stride);
+dst += zeros * atempo->stride;
+}
+
  // get the remaining data from the ring buffer:
  na = (atempo->head < atempo->tail ?
atempo->tail - atempo->head :
--
2.35.3



This is a reformatting of an earlier patch from Rajiv --
https://ffmpeg.org/pipermail/ffmpeg-devel/2024-March/322946.html
I've tested it locally -- looks good to me, feel free to apply and push.

Thanks for the review and reformatting. Would also check once on my end 
why the reformatting was required.


Committed in 4700925d22c79988688596bda8e862ef3ff39293 .

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

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


[FFmpeg-devel] [PATCH] fftools/ffmpeg_sched: Remove set-but-unused variable

2024-03-13 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_sched.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index d1fb942c34..f739066921 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -2310,7 +2310,6 @@ int sch_enc_send(Scheduler *sch, unsigned enc_idx, 
AVPacket *pkt)
 {
 SchEnc *enc;
 int ret;
-unsigned nb_done = 0;
 
 av_assert0(enc_idx < sch->nb_enc);
 enc = >enc[enc_idx];
@@ -2332,7 +2331,6 @@ int sch_enc_send(Scheduler *sch, unsigned enc_idx, 
AVPacket *pkt)
 if (ret < 0) {
 av_packet_unref(to_send);
 if (ret == AVERROR_EOF) {
-nb_done++;
 ret = 0;
 continue;
 }
-- 
2.40.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mpeg4videodec: Align idct-block appropriately

2024-03-13 Thread Kieran Kunhya
On Wed, 13 Mar 2024 at 00:53, Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> It is accessed via AV_RN64() in ff_simple_idct_put_int32_10bit().
> Should fix the UBSan failures in the mpeg4-simple-studio-profile
> test here:
>
> https://fate.ffmpeg.org/report.cgi?time=20240312011016=ppc-linux-gcc-13.2-ubsan-altivec-qemu
>
> Signed-off-by: Andreas Rheinhardt 
>

LGTM
___
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] Change rdiv (vf_convolution) documentation to reflect actual behavior

2024-03-13 Thread Marton Balint




On Tue, 12 Mar 2024, Stone Chen wrote:


The documentation correctly states that the rdiv is a multiplier but 
incorrectly states the default behavior is to multiply by the sum of all matrix 
elements - it multiplies by 1/sum.

This changes the documentation to match the code.


Please mention in the commit message the ticket number this patch fixes.

Thanks,
Marton



---
doc/filters.texi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index e0436a5755..913365671d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10497,7 +10497,7 @@ and from 1 to 49 odd number of signed integers in 
@var{row} mode.
@item 2rdiv
@item 3rdiv
Set multiplier for calculated value for each plane.
-If unset or 0, it will be sum of all matrix elements.
+If unset or 0, it will be 1/sum of all matrix elements.

@item 0bias
@item 1bias
--
2.44.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 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] [FFmpeg-cvslog] fftools/ffmpeg: add loopback decoding

2024-03-13 Thread Gyan Doshi




On 2024-03-13 12:57 pm, Anton Khirnov wrote:

ffmpeg | branch: master | Anton Khirnov  | Mon Feb 19 
10:27:44 2024 +0100| [a9193f7b7d65aafa326e25571c6672636a8ee3d2] | committer: Anton 
Khirnov

fftools/ffmpeg: add loopback decoding

...

+E.g. the following example:
+
+@example
+ffmpeg -i INPUT\
+  -map 0:v:0 -c:v libx264 -crf 45 -f null -\
+  -dec 0:0 -filter_complex '[0:v][dec:0]hstack[stack]' \
+  -map '[stack]' -c:v ffv1 OUTPUT


Can you add an example showing the assignment of a specific decoder 
along with a lavc generic + private option to a loopbacked stream?


Are there any limitations to loopback decoding e.g. would a vpx w/alpha 
encode be decoded back to a alpha pix fmt?


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

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


Re: [FFmpeg-devel] [PATCH v6 2/9] avcodec/vaapi_encode: introduce a base layer for vaapi encode

2024-03-13 Thread Wu, Tong1
>
>Feb 29, 2024, 06:35 by tong1.wu-at-intel@ffmpeg.org:
>
>> From: Tong Wu 
>>
>> Since VAAPI and future D3D12VA implementation may share the same dpb
>> logic and some other functions. A base layer encode context is introduced
>> as vaapi context's base and extract the related funtions to a common
>> file such as receive_packet, init, close, etc.
>>
>> Signed-off-by: Tong Wu 
>> ---
>>  libavcodec/Makefile |   2 +-
>>  libavcodec/hw_base_encode.c | 644 ++
>>  libavcodec/hw_base_encode.h | 252 +
>>  libavcodec/vaapi_encode.c   | 927 ++--
>>  libavcodec/vaapi_encode.h   | 202 +--
>>  libavcodec/vaapi_encode_av1.c   |  71 +--
>>  libavcodec/vaapi_encode_h264.c  | 199 +++
>>  libavcodec/vaapi_encode_h265.c  | 161 +++---
>>  libavcodec/vaapi_encode_mjpeg.c |  22 +-
>>  libavcodec/vaapi_encode_mpeg2.c |  51 +-
>>  libavcodec/vaapi_encode_vp8.c   |  26 +-
>>  libavcodec/vaapi_encode_vp9.c   |  68 +--
>>  12 files changed, 1400 insertions(+), 1225 deletions(-)
>>  create mode 100644 libavcodec/hw_base_encode.c
>>  create mode 100644 libavcodec/hw_base_encode.h
>>
>> +#define AVCODEC_HW_BASE_ENCODE_H
>> +
>> +#include "libavutil/hwcontext.h"
>> +#include "libavutil/fifo.h"
>> +
>> +#include "avcodec.h"
>> +
>> +static inline const char *ff_hw_base_encode_get_pictype_name(const int
>type) {
>> +const char * const picture_type_name[] = { "IDR", "I", "P", "B" };
>> +return picture_type_name[type];
>> +}
>> +
>> +enum {
>> +MAX_DPB_SIZE   = 16,
>> +MAX_PICTURE_REFERENCES = 2,
>>
>
>Only two max refs per picture?

For current VAAPI implementation yes.

>
>
>> +MAX_REORDER_DELAY  = 16,
>> +MAX_ASYNC_DEPTH= 64,
>> +MAX_REFERENCE_LIST_NUM = 2,
>> +};
>>
>
>Define these, don't enum them unnecessarily.

Sure.

>
>
>> +enum {
>> +PICTURE_TYPE_IDR = 0,
>> +PICTURE_TYPE_I   = 1,
>> +PICTURE_TYPE_P   = 2,
>> +PICTURE_TYPE_B   = 3,
>> +};
>> +
>> +enum {
>> +// Codec supports controlling the subdivision of pictures into slices.
>> +FLAG_SLICE_CONTROL = 1 << 0,
>> +// Codec only supports constant quality (no rate control).
>> +FLAG_CONSTANT_QUALITY_ONLY = 1 << 1,
>> +// Codec is intra-only.
>> +FLAG_INTRA_ONLY= 1 << 2,
>> +// Codec supports B-pictures.
>> +FLAG_B_PICTURES= 1 << 3,
>> +// Codec supports referencing B-pictures.
>> +FLAG_B_PICTURE_REFERENCES  = 1 << 4,
>> +// Codec supports non-IDR key pictures (that is, key pictures do
>> +// not necessarily empty the DPB).
>> +FLAG_NON_IDR_KEY_PICTURES  = 1 << 5,
>> +// Codec output packet without timestamp delay, which means the
>> +// output packet has same PTS and DTS.
>> +FLAG_TIMESTAMP_NO_DELAY= 1 << 6,
>>
>
>This is a low-level API. Concepts such as delay don't exist
>if you're the one setting up references.

I'll remove it from here and define this flag in vaapi_encode.h then.

>
>
>> +};
>> +
>> +typedef struct HWBaseEncodePicture {
>> +struct HWBaseEncodePicture *next;
>> +
>> +int64_t display_order;
>> +int64_t encode_order;
>> +int64_t pts;
>> +int64_t duration;
>> +int force_idr;
>> +
>> +void   *opaque;
>> +AVBufferRef*opaque_ref;
>> +
>> +int type;
>> +int b_depth;
>> +int encode_issued;
>> +int encode_complete;
>> +
>> +AVFrame*input_image;
>> +AVFrame*recon_image;
>> +
>> +void   *priv_data;
>> +
>> +// Whether this picture is a reference picture.
>> +int is_reference;
>> +
>> +// The contents of the DPB after this picture has been decoded.
>> +// This will contain the picture itself if it is a reference picture,
>> +// but not if it isn't.
>> +int nb_dpb_pics;
>> +struct HWBaseEncodePicture *dpb[MAX_DPB_SIZE];
>> +// The reference pictures used in decoding this picture. If they are
>> +// used by later pictures they will also appear in the DPB. ref[0][] for
>> +// previous reference frames. ref[1][] for future reference frames.
>> +int nb_refs[MAX_REFERENCE_LIST_NUM];
>> +struct HWBaseEncodePicture
>*refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES];
>> +// The previous reference picture in encode order.  Must be in at least
>> +// one of the reference list and DPB list.
>> +struct HWBaseEncodePicture *prev;
>> +// Reference count for other pictures referring to this one through
>> +// the above pointers, directly from incomplete pictures and indirectly
>> +// through completed pictures.
>> +int ref_count[2];
>> +int ref_removed[2];
>> +} HWBaseEncodePicture;
>> +
>> +typedef struct HWEncodePictureOperation {
>> +// Alloc memory for the picture structure.
>> +

Re: [FFmpeg-devel] [PATCH] change av_ts_make_time_string precision

2024-03-13 Thread Allan Cady via ffmpeg-devel
I've been meaning to ask -- what version of C are we using? I know it's at 
least 99,
because of the compound literal (had to look that up).
___
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] change av_ts_make_time_string precision

2024-03-13 Thread Allan Cady via ffmpeg-devel
On Tuesday, March 12, 2024 at 02:24:47 PM PDT, Marton Balint  
wrote: 
> On Tue, 12 Mar 2024, Allan Cady via ffmpeg-devel wrote:
>> On Monday, March 11, 2024 at 12:11:45 PM PDT, Marton Balint  
>> wrote:
>>> On Mon, 11 Mar 2024, Andreas Rheinhardt wrote:
>>> Allan Cady via ffmpeg-devel:
 From: "Allan Cady" 

 I propose changing the format to "%.6f", which will
 give microsecond precision for all timestamps, regardless of
 offset. Trailing zeros can be trimmed from the fraction, without
 losing precision. If the length of the fixed-precision formatted
 timestamp exceeds the length of the allocated buffer
 (AV_TS_MAX_STRING_SIZE, currently 32, less one for the
 terminating null), then we can fall back to scientific notation, though
 this seems almost certain to never occur, because 32 characters would
 allow a maximum timestamp value of (32 - 1 - 6 - 1) = 24 characters.
 By my calculation, 10^24 seconds is about six orders of magnitude
 greater than the age of the universe.

 The fix proposed here follows the following logic:

 1) Try formatting the number of seconds using "%.6f". This will
 always result in a string with six decimal digits in the fraction,
 possibly including trailing zeros. (e.g. "897234.73200").

 2) Check if that string would overflow the buffer. If it would, then
 format it using scientific notation ("%.8g").

 3) If the original fixed-point format fits, then trim any trailing
 zeros and decimal point, and return that result.

 Making this change broke two fate tests, filter-metadata-scdet,
 and filter-metadata-silencedetect. To correct this, I've modified
 tests/ref/fate/filter-metadata-scdet and
 tests/ref/fate/filter-metadata-silencedetect to match the
 new output.

 Signed-off-by: Allan Cady 
 ---
   libavutil/timestamp.h                        | 53 +++-
   tests/ref/fate/filter-metadata-scdet        | 12 ++---
   tests/ref/fate/filter-metadata-silencedetect |  2 +-
   3 files changed, 58 insertions(+), 9 deletions(-)

 diff --git a/libavutil/timestamp.h b/libavutil/timestamp.h
 index 2b37781eba..2f04f9bb2b 100644
 --- a/libavutil/timestamp.h
 +++ b/libavutil/timestamp.h
 @@ -25,6 +25,7 @@
   #define AVUTIL_TIMESTAMP_H

   #include "avutil.h"
 +#include 

   #if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) && 
!defined(PRId64)
   #error missing -D__STDC_FORMAT_MACROS / #define __STDC_FORMAT_MACROS
 @@ -53,6 +54,32 @@ static inline char *av_ts_make_string(char *buf, 
 int64_t ts)
   */
   #define av_ts2str(ts) 
av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)

 +/**
 + * Strip trailing zeros and decimal point from a string. Performed
 + * in-place on input buffer. For local use only by av_ts_make_time_string.
 + *
 + * e.g.:
 + * "752.378000" -> "752.378"
 + *        "4.0" -> "4"
 + *      "97300" -> "97300"
 + */
 +static inline void av_ts_strip_trailing_zeros_and_decimal_point(char 
 *str) {
 +    if (strchr(str, '.'))
 +    {
 +        int i;
 +        for (i = strlen(str) - 1; i >= 0 && str[i] == '0'; i--) {
 +            str[i] = '\0';
 +        }
 +
 +        // Remove decimal point if it's the last character
 +        if (i >= 0 && str[i] == '.') {
 +            str[i] = '\0';
 +        }
 +
 +        // String was modified in place; no need for return value.
 +    }
 +}
 +
   /**
   * Fill the provided buffer with a string containing a timestamp time
   * representation.
 @@ -65,8 +92,30 @@ static inline char *av_ts_make_string(char *buf, 
 int64_t ts)
   static inline char *av_ts_make_time_string(char *buf, int64_t ts,
                                             const AVRational *tb)
   {
 -    if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, 
 "NOPTS");
 -    else                      snprintf(buf, AV_TS_MAX_STRING_SIZE, 
 "%.6g", av_q2d(*tb) * ts);
 +    if (ts == AV_NOPTS_VALUE)
 +    {
 +        snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
 +    }
 +    else
 +    {
 +        const int max_fraction_digits = 6;
 +
 +        // Convert 64-bit timestamp to double, using rational timebase
 +        double seconds = av_q2d(*tb) * ts;
 +
 +        int length = snprintf(NULL, 0, "%.*f", max_fraction_digits, 
 seconds);
 +        if (length <= AV_TS_MAX_STRING_SIZE - 1)
 +        {
 +            snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.*f", 
 max_fraction_digits, seconds);
 +            av_ts_strip_trailing_zeros_and_decimal_point(buf);
 +        }
 +        else
 +        {
 +            snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.8g", seconds);
 +        }