Re: [FFmpeg-devel] [PATCH] Add AAC_xHE case to aacdec_template.c for demuxing

2024-04-02 Thread Lynne
Apr 2, 2024, 23:45 by ffmpeg-devel@ffmpeg.org:

> From: Ted Meyer 
>
> The parser needs to be able to be created when demuxing, otherwise the
> channel count and layout can't be successfully generated.
>
> Signed-off-by: Ted Meyer 
> ---
>  libavcodec/aacdec_template.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index aa856d7fe1..9afa3aba83 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -1022,6 +1022,7 @@ static int 
> decode_audio_specific_config_gb(AACDecContext *ac,
>  case AOT_AAC_LTP:
>  case AOT_ER_AAC_LC:
>  case AOT_ER_AAC_LD:
> +case AOT_USAC_NOSBR:
>  if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment,
>  m4ac, m4ac->chan_config)) < 0)
>  return ret;
>

That's a really invalid workaround which also disables warning users
that xHE-AAC is not implemented.
The xHE-AAC header is not an extension of the GA header to decode
anything properly, even without SBR.

I'll be posting patches in a few days to add xHE-AAC decoding support
which also fixes remuxing.
___
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] configure: Separate subsystem for Immersive Audio Model

2024-04-02 Thread Eugene Zemtsov via ffmpeg-devel
From: Eugene Zemtsov 

This change allows users to link ffmpeg as a library without
support for Immersive Audio Model by specifying --disable-iamf.
It helps to save on binary size in cases where it's important.

Signed-off-by: Eugene Zemtsov 
---
 configure |  7 ++-
 libavformat/mov.c | 15 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index d03e7e1631..56cc03f68a 100755
--- a/configure
+++ b/configure
@@ -141,6 +141,7 @@ Component options:
   --disable-lspdisable LSP code
   --disable-faan   disable floating point AAN (I)DCT code
   --disable-pixelutils disable pixel utils in libavutil
+  --disable-iamf   disable support for Immersive Audio Model
 
 Individual component options:
   --disable-everything disable all components listed below
@@ -2018,6 +2019,7 @@ SUBSYSTEM_LIST="
 lsp
 pixelutils
 network
+iamf
 "
 
 # COMPONENT_LIST needs to come last to ensure correct dependency checking
@@ -2806,6 +2808,8 @@ mpegvideoenc_select="aandcttables fdctdsp me_cmp 
mpegvideo pixblockdsp"
 msmpeg4dec_select="h263_decoder"
 msmpeg4enc_select="h263_encoder"
 vc1dsp_select="h264chroma qpeldsp startcode"
+iamfdec_deps="iamf"
+iamfenc_deps="iamf"
 
 # decoders / encoders
 aac_decoder_select="adts_header mpeg4audio sinewin"
@@ -3552,7 +3556,7 @@ matroska_demuxer_suggest="bzlib zlib"
 matroska_muxer_select="mpeg4audio riffenc aac_adtstoasc_bsf 
pgs_frame_merge_bsf vp9_superframe_bsf"
 mlp_demuxer_select="mlp_parser"
 mmf_muxer_select="riffenc"
-mov_demuxer_select="iso_media riffdec iamfdec"
+mov_demuxer_select="iso_media riffdec"
 mov_demuxer_suggest="zlib"
 mov_muxer_select="iso_media riffenc rtpenc_chain vp9_superframe_bsf 
aac_adtstoasc_bsf ac3_parser"
 mp3_demuxer_select="mpegaudio_parser"
@@ -4029,6 +4033,7 @@ enable safe_bitstream_reader
 enable static
 enable swscale_alpha
 enable valgrind_backtrace
+enable iamf iamfdec iamfenc
 
 sws_max_filter_size_default=256
 set_default sws_max_filter_size
diff --git a/libavformat/mov.c b/libavformat/mov.c
index c55778f3ef..662301bf67 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -839,6 +839,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+#if CONFIG_IAMFDEC
 static int mov_read_iacb(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
@@ -1015,6 +1016,7 @@ fail:
 
 return ret;
 }
+#endif
 
 static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
@@ -4797,6 +4799,7 @@ static void fix_timescale(MOVContext *c, MOVStreamContext 
*sc)
 }
 }
 
+#if CONFIG_IAMFDEC
 static int mov_update_iamf_streams(MOVContext *c, const AVStream *st)
 {
 const MOVStreamContext *sc = st->priv_data;
@@ -4840,6 +4843,7 @@ static int mov_update_iamf_streams(MOVContext *c, const 
AVStream *st)
 
 return 0;
 }
+#endif
 
 static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
@@ -4921,11 +4925,13 @@ static int mov_read_trak(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 mov_build_index(c, st);
 
+#if CONFIG_IAMFDEC
 if (sc->iamf) {
 ret = mov_update_iamf_streams(c, st);
 if (ret < 0)
 return ret;
 }
+#endif
 
 if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
 MOVDref *dref = >drefs[sc->dref_id - 1];
@@ -8457,7 +8463,9 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('i','p','r','p'), mov_read_iprp },
 { MKTAG('i','i','n','f'), mov_read_iinf },
 { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box 
*/
+#if CONFIG_IAMFDEC
 { MKTAG('i','a','c','b'), mov_read_iacb },
+#endif
 { 0, NULL }
 };
 
@@ -8929,8 +8937,10 @@ static void mov_free_stream_context(AVFormatContext *s, 
AVStream *st)
 av_freep(>coll);
 av_freep(>ambient);
 
+#if CONFIG_IAMFDEC
 if (sc->iamf)
 ff_iamf_read_deinit(sc->iamf);
+#endif
 av_freep(>iamf);
 }
 
@@ -9570,6 +9580,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 
 if (st->codecpar->codec_id == AV_CODEC_ID_EIA_608 && sample->size > 8)
 ret = get_eia608_packet(sc->pb, pkt, sample->size);
+#if CONFIG_IAMFDEC
 else if (sc->iamf) {
 int64_t pts, dts, pos, duration;
 int flags, size = sample->size;
@@ -9592,7 +9603,9 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 if (!ret)
 return FFERROR_REDO;
-} else
+}
+#endif
+else
 ret = av_get_packet(sc->pb, pkt, sample->size);
 if (ret < 0) {
 if (should_retry(sc->pb, ret)) {
-- 
2.44.0.478.gd926399ef9-goog

___
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 v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-04-02 Thread Wang, Fei W
On Tue, 2024-04-02 at 20:48 +0800, Nuo Mi wrote:
> 
> 
> On Thu, Mar 28, 2024 at 9:27 AM 
> wrote:
> > From: Fei Wang 
> > 
> > Signed-off-by: Fei Wang 
> > ---
> >  Changelog |   4 +
> >  configure |   3 +
> >  libavcodec/Makefile   |   1 +
> >  libavcodec/hwaccels.h |   1 +
> >  libavcodec/vaapi_decode.c |   7 +
> >  libavcodec/vaapi_vvc.c| 657
> > ++
> >  libavcodec/version.h  |   2 +-
> >  libavcodec/vvc/vvcdec.c   |  15 +-
> >  8 files changed, 688 insertions(+), 2 deletions(-)
> >  create mode 100644 libavcodec/vaapi_vvc.c
> > 
> > diff --git a/Changelog b/Changelog
> > index e83a00e35c..3108e65558 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -1,6 +1,10 @@
> >  Entries are sorted chronologically from oldest to youngest within
> > each release,
> >  releases are sorted from youngest to oldest.
> > 
> > +version :
> > +- VVC VAAPI decoder
> > +
> > +
> >  version 7.0:
> >  - DXV DXT1 encoder
> >  - LEAD MCMP decoder
> > diff --git a/configure b/configure
> > index 2a1d22310b..d902c9adc8 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3258,6 +3258,8 @@ vp9_vdpau_hwaccel_deps="vdpau
> > VdpPictureInfoVP9"
> >  vp9_vdpau_hwaccel_select="vp9_decoder"
> >  vp9_videotoolbox_hwaccel_deps="videotoolbox"
> >  vp9_videotoolbox_hwaccel_select="vp9_decoder"
> > +vvc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVVC"
> > +vvc_vaapi_hwaccel_select="vvc_decoder"
> >  wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
> >  wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
> >  wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel"
> > @@ -7250,6 +7252,7 @@ if enabled vaapi; then
> >  check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0,
> > 0)"
> > 
> >  check_type "va/va.h va/va_dec_hevc.h"
> > "VAPictureParameterBufferHEVC"
> > +check_type "va/va.h va/va_dec_vvc.h"
> > "VAPictureParameterBufferVVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9"
> > bit_depth
> >  check_struct "va/va.h" "VADecPictureParameterBufferAV1"
> > bit_depth_idx
> >  check_type   "va/va.h va/va_vpp.h"
> > "VAProcFilterParameterBufferHDRToneMapping"
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 9ce6d445c1..343b037636 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  +=
> > vaapi_vp9.o
> >  OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
> >  OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_vp9.o
> >  OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
> > +OBJS-$(CONFIG_VVC_VAAPI_HWACCEL)  += vaapi_vvc.o
> > 
> >  # Objects duplicated from other libraries for shared builds
> >  SHLIBOBJS  += log2_tab.o reverse.o
> > diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
> > index 5171e4c7d7..88d6b9a9b5 100644
> > --- a/libavcodec/hwaccels.h
> > +++ b/libavcodec/hwaccels.h
> > @@ -82,6 +82,7 @@ extern const struct FFHWAccel
> > ff_vp9_nvdec_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_vaapi_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_vdpau_hwaccel;
> >  extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel;
> > +extern const struct FFHWAccel ff_vvc_vaapi_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel;
> >  extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel;
> > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> > index 1b1972a2a9..ceeb1f1a12 100644
> > --- a/libavcodec/vaapi_decode.c
> > +++ b/libavcodec/vaapi_decode.c
> > @@ -455,6 +455,9 @@ static const struct {
> >  MAP(AV1, AV1_MAIN,AV1Profile0),
> >  MAP(AV1, AV1_HIGH,AV1Profile1),
> >  #endif
> > +#if VA_CHECK_VERSION(1, 22, 0)
> > +MAP(H266,VVC_MAIN_10, VVCMain10),
> > +#endif
> > 
> >  #undef MAP
> >  };
> > @@ -627,6 +630,10 @@ static int
> > vaapi_decode_make_config(AVCodecContext *avctx,
> >  case AV_CODEC_ID_VP8:
> >  frames->initial_pool_size += 3;
> >  break;
> > +case AV_CODEC_ID_H266:
> > +// Add additional 16 for maximum 16 frames delay in
> > vvc native decode.
> > +frames->initial_pool_size += 32;
> 
> One frame of 8k YUV444, 10 bits, is about 200MB. Thirty-two frames
> amount to approximately 6GB.Can we dynamically allocate the buffer
> pool? 

It's processing in other thread:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11316

> 
> The software decoder requires a delay of 16 frames to ensure full
> utilization of CPUs. In the future, we may consider increasing this
> to 32 or even 64 frames.
> However, for hardware decoding, given that all processing occurs on
> the GPU, we do not require any delay.

The delay can avoid sync hardware task immediately once it is
submitted, which can avoid hardware switch tasks 

Re: [FFmpeg-devel] [PATCH 1/3] lavu/hwcontext_vaapi: Add a new quirk

2024-04-02 Thread Xiang, Haihao
On Do, 2024-03-28 at 10:17 +0800, Xiang, Haihao wrote:
> From: Haihao Xiang 
> 
> libva2 doesn't require a fixed surface-array any more, but some
> driver/hardware combinations which rely on this are still used. To
> reduce the impact to users, add a quirk for the driver/hardware
> combination which supports dynamic surface pool.
> 
> Signed-off-by: Haihao Xiang 
> ---
>  libavutil/hwcontext_vaapi.c | 7 +++
>  libavutil/hwcontext_vaapi.h | 6 ++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> index 56d03aa4cd..dae5dd4a11 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -390,6 +390,13 @@ static const struct {
>  "Splitted-Desktop Systems VDPAU backend for VA-API",
>  AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES,
>  },
> +#if CONFIG_VAAPI_1
> +    {
> +    "New Intel iHD",
> +    "Intel iHD driver for Intel(R) Gen Graphics",
> +    AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL,
> +    },
> +#endif
>  };
>  
>  static int vaapi_device_init(AVHWDeviceContext *hwdev)
> diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h
> index 0b2e071cb3..07014fd526 100644
> --- a/libavutil/hwcontext_vaapi.h
> +++ b/libavutil/hwcontext_vaapi.h
> @@ -58,6 +58,12 @@ enum {
>   * and the results of the vaQuerySurfaceAttributes() call will be faked.
>   */
>  AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3),
> +
> +    /**
> + * The driver (and the underlying HW) supports dynamic surface pool.
> + * The vaCreateContext() call doesn't require a fixed surface-array.
> + */
> +    AV_VAAPI_DRIVER_QUIRK_DYNAMIC_SURFACE_POOL = (1 << 4),
>  };
>  
>  /**

I will merge this patchset if there are no objections.

Thanks
Haihao

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

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


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_hevc: Add support for Main Intra & Main 10 Intra

2024-04-02 Thread Xiang, Haihao
On Di, 2024-04-02 at 22:01 +0100, Mark Thompson wrote:
> On 02/04/2024 07:55, Xiang, Haihao wrote:
> > On Ma, 2024-04-01 at 21:11 +0100, Mark Thompson wrote:
> > > On 28/03/2024 02:07, Xiang, Haihao wrote:
> > > > From: Haihao Xiang 
> > > > 
> > > > Both Main Intra and Main 10 Intra are Rext, we may use Main and Main 10
> > > > instead for decoding. This patch fixes the error below:
> > > > 
> > > > [hevc @ 0x55a771b80a00] No support for codec hevc profile 4.
> > > > [hevc @ 0x55a771b80a00] Failed setup for format vaapi: hwaccel
> > > > initialisation returned error.
> > > > 
> > > > Signed-off-by: Haihao Xiang 
> > > > ---
> > > >    libavcodec/vaapi_hevc.c | 7 +++
> > > >    1 file changed, 7 insertions(+)
> > > > 
> > > > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> > > > index 3bdd2dd1b8..83b94d1a55 100644
> > > > --- a/libavcodec/vaapi_hevc.c
> > > > +++ b/libavcodec/vaapi_hevc.c
> > > > @@ -612,6 +612,13 @@ VAProfile
> > > > ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
> > > >    av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n",
> > > > profile->name);
> > > >    }
> > > >    
> > > > +#if VA_CHECK_VERSION(0, 37, 0)
> > > > +    if (!strcmp(profile->name, "Main Intra"))
> > > > +    return VAProfileHEVCMain;
> > > > +    else if (!strcmp(profile->name, "Main 10 Intra"))
> > > > +    return VAProfileHEVCMain10;
> > > > +#endif
> > > > +
> > > >    #if VA_CHECK_VERSION(1, 2, 0)
> > > >    if (!strcmp(profile->name, "Main 12") ||
> > > >    !strcmp(profile->name, "Main 12 Intra"))
> > > 
> > > What if high_precision_offsets_enabled_flag is set?
> > > 
> > > (That doesn't matter for the VAAPI encoder setting the profile because we
> > > always have it as zero.)
> > 
> > Here use VAProfileHEVCMain or VAProfileHEVCMain10 to create VAConfig for
> > decoding,  avctx->profile (4) is not changed.
> > high_precision_offsets_enabled_flag is set in
> > VAPictureParameterBufferHEVCRext
> > when avctx->profile is 4.
> 
> But Main and Main 10 profile have:
> 
> "Active SPSs for the base layer shall have ...
> high_precision_offsets_enabled_flag, ... when present, equal to 0 only."
> 
> so a decoder implementing those profiles need not support it.  (It may work as
> a compatible extension as the field is there, but if it doesn't also support
> general rext cases then this is unlikely to be implemented.)
> 

I get your point, the underlying driver mightn't support
VAPictureParameterBufferHEVCRext. Seems we should add new profiles in libva. 

Thanks
Haihao

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

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


[FFmpeg-devel] [PATCH] doc/developer: (security) researchers should be credited

2024-04-02 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 doc/developer.texi | 4 
 1 file changed, 4 insertions(+)

diff --git a/doc/developer.texi b/doc/developer.texi
index c86bb5820cc..63835dfa06c 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -390,6 +390,10 @@ If you apply a patch, send an
 answer to ffmpeg-devel (or wherever you got the patch from) saying that
 you applied the patch.
 
+@subheading Credit any researchers
+If a commit/patch fixes an issues found by some researcher, always credit the
+researcher in the commit message for finding/reporting the issue.
+
 @subheading Always wait long enough before pushing changes
 Do NOT commit to code actively maintained by others without permission.
 Send a patch to ffmpeg-devel. If no one answers within a reasonable
-- 
2.17.1

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

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


Re: [FFmpeg-devel] [PATCH 1/6] avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()

2024-04-02 Thread James Almer

On 4/2/2024 7:22 PM, Marton Balint wrote:



On Mon, 1 Apr 2024, James Almer wrote:


On 4/1/2024 8:40 PM, Michael Niedermayer wrote:

 On Mon, Apr 01, 2024 at 06:33:22PM -0300, James Almer wrote:

 On 4/1/2024 5:56 PM, Michael Niedermayer wrote:

Fixes:  memleak
Fixes:  
67442/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5068813261406208


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

 diff --git a/libavformat/isom.c b/libavformat/isom.c
 index 9fbccd4437f..c5930bd4d87 100644
 --- a/libavformat/isom.c
 +++ b/libavformat/isom.c
 @@ -359,6 +359,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext
 *fc, AVStream *st, AVIOContext

st->codecpar->extradata_size,

    1, fc);
    if (ret < 0)
    return ret;
 +    av_channel_layout_uninit(>codecpar->ch_layout);
    st->codecpar->ch_layout.order = 
AV_CHANNEL_ORDER_UNSPEC;


 Not strictly related to this fix, but should we really drop the layout
 here
 by forcing unspec? We're also not even bothering to check if 
cfg.channels

 matches st->codecpar->ch_layout.nb_channels.


 I was wondering the same.
 I was hoping someone would know the specs well enouh to just say 
straight

 "this and that isnt legal together error out if thats true"


Maybe Marton knows, since he's been working on this code.


I don't really know for sure. But it would make sense to me to only drop 
the layout if the channel count is different from what we already know.


Ok, just did that, and also applied Michael's memleak fix. Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] Make Immersive Audio Model optional for MOV demuxing

2024-04-02 Thread James Almer

On 4/2/2024 7:50 PM, Eugene Zemtsov via ffmpeg-devel wrote:

Is there anything I can do to get this path applied?
I can make iamfdec optional for mov demuxer in the same change if it's
something you're willing to do.


This change as is is not ok because CONFIG_IAMFDEC is always true when 
building the mov demuxer. It's a change that very clearly will depend on 
a custom config.h/mak as modified by projects using ffmpeg.


But yes, your suggestion is ok. Simpler way is probably how faan is 
handled in configure: Add a new iamf entry to SUBSYSTEM_LIST and make 
iamfdec and iamfenc depend on it. Also list the relevant --disable-iamf 
option to the output of configure --help, alongside --disable-faan and 
similar.




On Wed, Mar 27, 2024 at 5:43 PM Eugene Zemtsov  wrote:



Can you elaborate why you need this? In configure the mov demuxer
selects iamfdec, so it will always be present and compiled.


Chromium doesn't use Immersive Audio, but the code for handling it
bloats Android binaries,
that's why we disabled it.

I have a second patch that disables iamfdec by default for mov demuxer,
but I had a feeling that maintainers will be less inclined to accept
it and that's why I split it from this one.
I will still try to send it if this patch is accepted.


On Wed, Mar 27, 2024 at 4:59 PM James Almer  wrote:


On 3/27/2024 8:55 PM, Eugene Zemtsov via ffmpeg-devel wrote:

From: Eugene Zemtsov 

Signed-off-by: Eugene Zemtsov 
---
   libavformat/mov.c | 15 ++-
   1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index c55778f3ef..662301bf67 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -839,6 +839,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
   return 0;
   }

+#if CONFIG_IAMFDEC
   static int mov_read_iacb(MOVContext *c, AVIOContext *pb, MOVAtom atom)
   {
   AVStream *st;
@@ -1015,6 +1016,7 @@ fail:

   return ret;
   }
+#endif

   static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
   {
@@ -4797,6 +4799,7 @@ static void fix_timescale(MOVContext *c, MOVStreamContext 
*sc)
   }
   }

+#if CONFIG_IAMFDEC
   static int mov_update_iamf_streams(MOVContext *c, const AVStream *st)
   {
   const MOVStreamContext *sc = st->priv_data;
@@ -4840,6 +4843,7 @@ static int mov_update_iamf_streams(MOVContext *c, const 
AVStream *st)

   return 0;
   }
+#endif

   static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
   {
@@ -4921,11 +4925,13 @@ static int mov_read_trak(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)

   mov_build_index(c, st);

+#if CONFIG_IAMFDEC
   if (sc->iamf) {
   ret = mov_update_iamf_streams(c, st);
   if (ret < 0)
   return ret;
   }
+#endif

   if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
   MOVDref *dref = >drefs[sc->dref_id - 1];
@@ -8457,7 +8463,9 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
   { MKTAG('i','p','r','p'), mov_read_iprp },
   { MKTAG('i','i','n','f'), mov_read_iinf },
   { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment 
box */
+#if CONFIG_IAMFDEC
   { MKTAG('i','a','c','b'), mov_read_iacb },
+#endif
   { 0, NULL }
   };

@@ -8929,8 +8937,10 @@ static void mov_free_stream_context(AVFormatContext *s, 
AVStream *st)
   av_freep(>coll);
   av_freep(>ambient);

+#if CONFIG_IAMFDEC
   if (sc->iamf)
   ff_iamf_read_deinit(sc->iamf);
+#endif
   av_freep(>iamf);
   }

@@ -9570,6 +9580,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)

   if (st->codecpar->codec_id == AV_CODEC_ID_EIA_608 && sample->size > 
8)
   ret = get_eia608_packet(sc->pb, pkt, sample->size);
+#if CONFIG_IAMFDEC
   else if (sc->iamf) {
   int64_t pts, dts, pos, duration;
   int flags, size = sample->size;
@@ -9592,7 +9603,9 @@ static int mov_read_packet(AVFormatContext *s, AVPacket 
*pkt)
   }
   if (!ret)
   return FFERROR_REDO;
-} else
+}
+#endif
+else
   ret = av_get_packet(sc->pb, pkt, sample->size);
   if (ret < 0) {
   if (should_retry(sc->pb, ret)) {


Can you elaborate why you need this? In configure the mov demuxer
selects iamfdec, so it will always be present and compiled.
___
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".




--
Thanks,
Eugene Zemtsov.





___
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] Make Immersive Audio Model optional for MOV demuxing

2024-04-02 Thread Eugene Zemtsov via ffmpeg-devel
Is there anything I can do to get this path applied?
I can make iamfdec optional for mov demuxer in the same change if it's
something you're willing to do.

On Wed, Mar 27, 2024 at 5:43 PM Eugene Zemtsov  wrote:
>
> > Can you elaborate why you need this? In configure the mov demuxer
> > selects iamfdec, so it will always be present and compiled.
>
> Chromium doesn't use Immersive Audio, but the code for handling it
> bloats Android binaries,
> that's why we disabled it.
>
> I have a second patch that disables iamfdec by default for mov demuxer,
> but I had a feeling that maintainers will be less inclined to accept
> it and that's why I split it from this one.
> I will still try to send it if this patch is accepted.
>
>
> On Wed, Mar 27, 2024 at 4:59 PM James Almer  wrote:
> >
> > On 3/27/2024 8:55 PM, Eugene Zemtsov via ffmpeg-devel wrote:
> > > From: Eugene Zemtsov 
> > >
> > > Signed-off-by: Eugene Zemtsov 
> > > ---
> > >   libavformat/mov.c | 15 ++-
> > >   1 file changed, 14 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > > index c55778f3ef..662301bf67 100644
> > > --- a/libavformat/mov.c
> > > +++ b/libavformat/mov.c
> > > @@ -839,6 +839,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext 
> > > *pb, MOVAtom atom)
> > >   return 0;
> > >   }
> > >
> > > +#if CONFIG_IAMFDEC
> > >   static int mov_read_iacb(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> > >   {
> > >   AVStream *st;
> > > @@ -1015,6 +1016,7 @@ fail:
> > >
> > >   return ret;
> > >   }
> > > +#endif
> > >
> > >   static int mov_read_dec3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> > >   {
> > > @@ -4797,6 +4799,7 @@ static void fix_timescale(MOVContext *c, 
> > > MOVStreamContext *sc)
> > >   }
> > >   }
> > >
> > > +#if CONFIG_IAMFDEC
> > >   static int mov_update_iamf_streams(MOVContext *c, const AVStream *st)
> > >   {
> > >   const MOVStreamContext *sc = st->priv_data;
> > > @@ -4840,6 +4843,7 @@ static int mov_update_iamf_streams(MOVContext *c, 
> > > const AVStream *st)
> > >
> > >   return 0;
> > >   }
> > > +#endif
> > >
> > >   static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> > >   {
> > > @@ -4921,11 +4925,13 @@ static int mov_read_trak(MOVContext *c, 
> > > AVIOContext *pb, MOVAtom atom)
> > >
> > >   mov_build_index(c, st);
> > >
> > > +#if CONFIG_IAMFDEC
> > >   if (sc->iamf) {
> > >   ret = mov_update_iamf_streams(c, st);
> > >   if (ret < 0)
> > >   return ret;
> > >   }
> > > +#endif
> > >
> > >   if (sc->dref_id-1 < sc->drefs_count && 
> > > sc->drefs[sc->dref_id-1].path) {
> > >   MOVDref *dref = >drefs[sc->dref_id - 1];
> > > @@ -8457,7 +8463,9 @@ static const MOVParseTableEntry 
> > > mov_default_parse_table[] = {
> > >   { MKTAG('i','p','r','p'), mov_read_iprp },
> > >   { MKTAG('i','i','n','f'), mov_read_iinf },
> > >   { MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing 
> > > environment box */
> > > +#if CONFIG_IAMFDEC
> > >   { MKTAG('i','a','c','b'), mov_read_iacb },
> > > +#endif
> > >   { 0, NULL }
> > >   };
> > >
> > > @@ -8929,8 +8937,10 @@ static void 
> > > mov_free_stream_context(AVFormatContext *s, AVStream *st)
> > >   av_freep(>coll);
> > >   av_freep(>ambient);
> > >
> > > +#if CONFIG_IAMFDEC
> > >   if (sc->iamf)
> > >   ff_iamf_read_deinit(sc->iamf);
> > > +#endif
> > >   av_freep(>iamf);
> > >   }
> > >
> > > @@ -9570,6 +9580,7 @@ static int mov_read_packet(AVFormatContext *s, 
> > > AVPacket *pkt)
> > >
> > >   if (st->codecpar->codec_id == AV_CODEC_ID_EIA_608 && 
> > > sample->size > 8)
> > >   ret = get_eia608_packet(sc->pb, pkt, sample->size);
> > > +#if CONFIG_IAMFDEC
> > >   else if (sc->iamf) {
> > >   int64_t pts, dts, pos, duration;
> > >   int flags, size = sample->size;
> > > @@ -9592,7 +9603,9 @@ static int mov_read_packet(AVFormatContext *s, 
> > > AVPacket *pkt)
> > >   }
> > >   if (!ret)
> > >   return FFERROR_REDO;
> > > -} else
> > > +}
> > > +#endif
> > > +else
> > >   ret = av_get_packet(sc->pb, pkt, sample->size);
> > >   if (ret < 0) {
> > >   if (should_retry(sc->pb, ret)) {
> >
> > Can you elaborate why you need this? In configure the mov demuxer
> > selects iamfdec, so it will always be present and compiled.
> > ___
> > 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".
>
>
>
> --
> Thanks,
> Eugene Zemtsov.



-- 
Thanks,
Eugene Zemtsov.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link 

[FFmpeg-devel] [PATCH v2 1/4] avformat/mov_chan: check channel count of layout tags at compile time

2024-04-02 Thread Marton Balint
We can do this by using an X-macro for channel map declaration and doing a
static_assert() in one pass for the check. Thanks for Andreas Rheinhardt for
the suggestion.

Signed-off-by: Marton Balint 
---
 libavformat/mov_chan.c | 217 -
 1 file changed, 108 insertions(+), 109 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index e7d181d71f..4bb0ee7405 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -23,6 +23,7 @@
  * @author Justin Ruggles
  */
 
+#include 
 #include 
 
 #include "libavutil/avassert.h"
@@ -81,108 +82,114 @@ struct MovChannelLayoutMap {
 };
 };
 
-#define TAG(_0)  {.tag = _0}
-#define ID(_0)   {.id = c_##_0}
-#define CHLIST(_0, ...)  TAG(_0), __VA_ARGS__
-#define CHLIST01(_0, _1) CHLIST(_0, ID(_1))
-#define CHLIST02(_0, _1, _2) CHLIST(_0, ID(_1), 
ID(_2))
-#define CHLIST03(_0, _1, _2, _3) CHLIST(_0, ID(_1), 
ID(_2), ID(_3))
-#define CHLIST04(_0, _1, _2, _3, _4) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4))
-#define CHLIST05(_0, _1, _2, _3, _4, _5) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4), ID(_5))
-#define CHLIST06(_0, _1, _2, _3, _4, _5, _6) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4), ID(_5), ID(_6))
-#define CHLIST07(_0, _1, _2, _3, _4, _5, _6, _7) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7))
-#define CHLIST08(_0, _1, _2, _3, _4, _5, _6, _7, _8) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8))
-#define CHLIST09(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) CHLIST(_0, ID(_1), 
ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9))
-#define CHLIST16(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, 
_14, _15, _16) \
-CHLIST(_0, ID(_1),  ID(_2),  ID(_3),  ID(_4),  ID(_5),  ID(_6), ID(_7), 
ID(_8), ID(_9), ID(_10), \
-   ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16))
-#define CHLIST21(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, 
_14, _15, _16, _17, _18, _19, _20, _21) \
-CHLIST(_0, ID(_1),  ID(_2),  ID(_3),  ID(_4),  ID(_5),  ID(_6),  ID(_7),  
ID(_8),  ID(_9),  ID(_10), \
-   ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16), ID(_17), 
ID(_18), ID(_19), ID(_20), ID(_21))
-
+#define TAG(_tag, _cnt){.tag = _tag}
+#define ID(_0) {.id = c_##_0}
+#define CHLIST01(_tag, _1) CHLIST(_tag, 1, 
ID(_1))
+#define CHLIST02(_tag, _1, _2) CHLIST(_tag, 2, 
ID(_1), ID(_2))
+#define CHLIST03(_tag, _1, _2, _3) CHLIST(_tag, 3, 
ID(_1), ID(_2), ID(_3))
+#define CHLIST04(_tag, _1, _2, _3, _4) CHLIST(_tag, 4, 
ID(_1), ID(_2), ID(_3), ID(_4))
+#define CHLIST05(_tag, _1, _2, _3, _4, _5) CHLIST(_tag, 5, 
ID(_1), ID(_2), ID(_3), ID(_4), ID(_5))
+#define CHLIST06(_tag, _1, _2, _3, _4, _5, _6) CHLIST(_tag, 6, 
ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6))
+#define CHLIST07(_tag, _1, _2, _3, _4, _5, _6, _7) CHLIST(_tag, 7, 
ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7))
+#define CHLIST08(_tag, _1, _2, _3, _4, _5, _6, _7, _8) CHLIST(_tag, 8, 
ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8))
+#define CHLIST09(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9) CHLIST(_tag, 9, 
ID(_1), ID(_2), ID(_3), ID(_4), ID(_5), ID(_6), ID(_7), ID(_8), ID(_9))
+#define CHLIST16(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, 
_14, _15, _16) \
+CHLIST(_tag, 16, ID(_1),  ID(_2),  ID(_3),  ID(_4),  ID(_5),  ID(_6), 
ID(_7), ID(_8), ID(_9), ID(_10), \
+ ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16))
+#define CHLIST21(_tag, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, 
_14, _15, _16, _17, _18, _19, _20, _21) \
+CHLIST(_tag, 21, ID(_1),  ID(_2),  ID(_3),  ID(_4),  ID(_5),  ID(_6),  
ID(_7),  ID(_8),  ID(_9),  ID(_10), \
+ ID(_11), ID(_12), ID(_13), ID(_14), ID(_15), ID(_16), 
ID(_17), ID(_18), ID(_19), ID(_20), ID(_21))
+
+#define MOV_CH_LAYOUT_MAP \
+CHLIST01( MOV_CH_LAYOUT_MONO, C)\
+CHLIST02( MOV_CH_LAYOUT_STEREO,   L,   R)\
+CHLIST02( MOV_CH_LAYOUT_STEREOHEADPHONES, L,   R)\
+CHLIST02( MOV_CH_LAYOUT_BINAURAL, L,   R)\
+CHLIST02( MOV_CH_LAYOUT_MIDSIDE,  L,   R)\
+CHLIST02( MOV_CH_LAYOUT_XY,   L,   R)\
+CHLIST02( MOV_CH_LAYOUT_MATRIXSTEREO, Lt,  Rt   )\
+CHLIST02( MOV_CH_LAYOUT_AC3_1_0_1,C,   LFE  )\
+CHLIST03( MOV_CH_LAYOUT_MPEG_3_0_A,   L,   R,   C )\
+CHLIST03( MOV_CH_LAYOUT_MPEG_3_0_B,   C,   

Re: [FFmpeg-devel] [PATCH 1/6] avformat/isom: Uninit layout in ff_mp4_read_dec_config_descr()

2024-04-02 Thread Marton Balint




On Mon, 1 Apr 2024, James Almer wrote:


On 4/1/2024 8:40 PM, Michael Niedermayer wrote:

 On Mon, Apr 01, 2024 at 06:33:22PM -0300, James Almer wrote:

 On 4/1/2024 5:56 PM, Michael Niedermayer wrote:

Fixes:  memleak
Fixes:  
67442/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5068813261406208

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

 diff --git a/libavformat/isom.c b/libavformat/isom.c
 index 9fbccd4437f..c5930bd4d87 100644
 --- a/libavformat/isom.c
 +++ b/libavformat/isom.c
 @@ -359,6 +359,7 @@ int ff_mp4_read_dec_config_descr(AVFormatContext
 *fc, AVStream *st, AVIOContext

st->codecpar->extradata_size,
1, fc);
if (ret < 0)
return ret;
 +av_channel_layout_uninit(>codecpar->ch_layout);
st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;


 Not strictly related to this fix, but should we really drop the layout
 here
 by forcing unspec? We're also not even bothering to check if cfg.channels
 matches st->codecpar->ch_layout.nb_channels.


 I was wondering the same.
 I was hoping someone would know the specs well enouh to just say straight
 "this and that isnt legal together error out if thats true"


Maybe Marton knows, since he's been working on this code.


I don't really know for sure. But it would make sense to me to only drop 
the layout if the channel count is different from what we already know.


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

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


[FFmpeg-devel] [PATCH] lavc/vvc: Only read split_cu_flag if a split is allowed

2024-04-02 Thread Frank Plowman
Add a check to ensure some split is possible before reading the
split_cu_flag.  This is present in the spec, in VVCv3 section 7.3.11.4.
Its omission could lead to infinite loops and ultimately crashing due to
stack overflow.
---
 libavcodec/vvc/vvc_ctu.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vvc/vvc_ctu.c b/libavcodec/vvc/vvc_ctu.c
index 8ba12c8d9f..32d8bc8f5c 100644
--- a/libavcodec/vvc/vvc_ctu.c
+++ b/libavcodec/vvc/vvc_ctu.c
@@ -2095,6 +2095,7 @@ static int hls_coding_tree(VVCLocalContext *lc,
 const int ch_type   = tree_type_curr == DUAL_TREE_CHROMA;
 int ret;
 VVCAllowedSplit allowed;
+int split_cu_flag;
 
 if (pps->r->pps_cu_qp_delta_enabled_flag && qg_on_y && cb_sub_div <= 
sh->cu_qp_delta_subdiv) {
 lc->parse.is_cu_qp_delta_coded = 0;
@@ -2109,7 +2110,11 @@ static int hls_coding_tree(VVCLocalContext *lc,
 
 can_split(lc, x0, y0, cb_width, cb_height, mtt_depth, depth_offset, 
part_idx,
 last_split_mode, tree_type_curr, mode_type_curr, );
-if (ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, ch_type, 
)) {
+if (allowed.btv || allowed.bth || allowed.ttv || allowed.tth || allowed.qt)
+split_cu_flag = ff_vvc_split_cu_flag(lc, x0, y0, cb_width, cb_height, 
ch_type, );
+else
+split_cu_flag = 0;
+if (split_cu_flag) {
 VVCSplitMode split  = ff_vvc_split_mode(lc, x0, y0, cb_width, 
cb_height, cqt_depth, mtt_depth, ch_type, );
 VVCModeType mode_type   = mode_type_decode(lc, x0, y0, cb_width, 
cb_height, split, ch_type, mode_type_curr);
 
-- 
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] [PATCH] Add AAC_xHE case to aacdec_template.c for demuxing

2024-04-02 Thread Ted Meyer via ffmpeg-devel
From: Ted Meyer 

The parser needs to be able to be created when demuxing, otherwise the
channel count and layout can't be successfully generated.

Signed-off-by: Ted Meyer 
---
 libavcodec/aacdec_template.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index aa856d7fe1..9afa3aba83 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1022,6 +1022,7 @@ static int decode_audio_specific_config_gb(AACDecContext 
*ac,
 case AOT_AAC_LTP:
 case AOT_ER_AAC_LC:
 case AOT_ER_AAC_LD:
+case AOT_USAC_NOSBR:
 if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
-- 
2.44.0.478.gd926399ef9-goog

___
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] avformat/demux: fix accurate probing of durations in mpegts/ps

2024-04-02 Thread Nicolas Gaullier
Two issues affect accuracy of duration in estimate_timings_from_pts():
- pkt->duration typically reports the duration of a single audio frame,
whereas a pes often contain several audio frames
- for video, compute_frame_duration() use r_frame_rate which is not
reliable; typically, it is the duration of a single field for an
interlaced video using two field pictures.

Packet splitting/parsing is required to get accurate durations, so this
patch replaces ff_read_packet() calls by av_read_frame() calls.

Note that concatdec makes use of avformat_find_stream_info() to stitch
correctly the files, so it benefits from this patch (typically, overlap
is avoided).
e.g. in fate/concat-demuxer-simple2-lavf-ts: the input audio stream
duration is now longer than that of the video, which results in
concatdec joining on audio after the patch instead of joining on video
before that.

Signed-off-by: Nicolas Gaullier 
---
 libavformat/demux.c   |  36 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 170 +-
 tests/ref/fate/ts-opus-demux  |   4 +-
 3 files changed, 100 insertions(+), 110 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index abfd5fee7d..f017bae094 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1808,12 +1808,12 @@ static void 
estimate_timings_from_bit_rate(AVFormatContext *ic)
 #define DURATION_DEFAULT_MAX_RETRY 6
 #define DURATION_MAX_RETRY 1
 
-/* only usable for MPEG-PS streams */
+/* only usable for MPEG-PS/TS streams */
 static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
 {
 FFFormatContext *const si = ffformatcontext(ic);
 AVPacket *const pkt = si->pkt;
-int num, den, read_size, ret;
+int read_size, ret;
 int64_t duration_max_read_size = ic->duration_probesize ? 
ic->duration_probesize >> DURATION_MAX_RETRY : DURATION_DEFAULT_MAX_READ_SIZE;
 int duration_max_retry = ic->duration_probesize ? DURATION_MAX_RETRY : 
DURATION_DEFAULT_MAX_RETRY;
 int found_duration = 0;
@@ -1821,9 +1821,6 @@ static void estimate_timings_from_pts(AVFormatContext 
*ic, int64_t old_offset)
 int64_t filesize, offset, duration;
 int retry = 0;
 
-/* flush packet queue */
-ff_flush_packet_queue(ic);
-
 for (unsigned i = 0; i < ic->nb_streams; i++) {
 AVStream *const st  = ic->streams[i];
 FFStream *const sti = ffstream(st);
@@ -1834,10 +1831,13 @@ static void estimate_timings_from_pts(AVFormatContext 
*ic, int64_t old_offset)
 av_log(ic, AV_LOG_WARNING,
"start time for stream %d is not set in 
estimate_timings_from_pts\n", i);
 
-if (sti->parser) {
-av_parser_close(sti->parser);
-sti->parser = NULL;
-}
+/* Demuxer context updates may occur, particularly while seeking in 
mpegts,
+ * and this could loose codec parameters in avctx,
+ * so preserve them in codecpar.
+ */
+if (sti->avctx_inited &&
+avcodec_parameters_from_context(st->codecpar, sti->avctx))
+goto skip_duration_calc;
 }
 
 if (ic->skip_estimate_duration_from_pts) {
@@ -1855,6 +1855,7 @@ static void estimate_timings_from_pts(AVFormatContext 
*ic, int64_t old_offset)
 if (offset < 0)
 offset = 0;
 
+ff_read_frame_flush(ic);
 avio_seek(ic->pb, offset, SEEK_SET);
 read_size = 0;
 for (;;) {
@@ -1864,7 +1865,7 @@ static void estimate_timings_from_pts(AVFormatContext 
*ic, int64_t old_offset)
 break;
 
 do {
-ret = ff_read_packet(ic, pkt);
+ret = av_read_frame(ic, pkt);
 } while (ret == AVERROR(EAGAIN));
 if (ret != 0)
 break;
@@ -1874,15 +1875,6 @@ static void estimate_timings_from_pts(AVFormatContext 
*ic, int64_t old_offset)
 if (pkt->pts != AV_NOPTS_VALUE &&
 (st->start_time != AV_NOPTS_VALUE ||
  sti->first_dts != AV_NOPTS_VALUE)) {
-if (pkt->duration == 0) {
-compute_frame_duration(ic, , , st, sti->parser, 
pkt);
-if (den && num) {
-pkt->duration = av_rescale_rnd(1,
-   num * (int64_t) st->time_base.den,
-   den * (int64_t) st->time_base.num,
-   AV_ROUND_DOWN);
-}
-}
 duration = pkt->pts + pkt->duration;
 found_duration = 1;
 if (st->start_time != AV_NOPTS_VALUE)
@@ -1938,15 +1930,13 @@ skip_duration_calc:
 fill_all_stream_timings(ic);
 
 avio_seek(ic->pb, old_offset, SEEK_SET);
+
+ff_read_frame_flush(ic);
 for (unsigned i = 0; i < ic->nb_streams; i++) {
 AVStream *const st  = ic->streams[i];
 FFStream *const sti = ffstream(st);
 
 

[FFmpeg-devel] [PATCH v3 0/1] avformat/demux: fix accurate probing of durations in mpegts/ps

2024-04-02 Thread Nicolas Gaullier
v3: rebased after ed9363052f4b8b8 applied tonight (add duration_probesize 
AVOption)

Note: I have no other plan for demux/probing; with these two patches, I can 
cover my use cases, especially mpegts-concats.

For remembering, previous cover-letters:

v1
ff_read_packet() is more lightweight, but it leads to important issues when 
looking for accurate durations.
As a side effect, the code looks also simpler with regular av_read_frame() 
calls.
1)Updates in the fate tests do exhibit most of the results.

2)See also more directly the case of an audio PES containing many frames:
>ffprobe tests/data/lavf/lavf.ts -select_streams a -show_entries 
>stream=duration -of flat
Before patch:
  streams.stream.0.duration="0.757556"
After patch:
  streams.stream.0.duration="1.018778"

3)Here is an additional (commonplace) sample to demonstrate the benefit for 
twofields-encoded video:
https://0x0.st/HFbm.ts (say h264-50i_mp2.ts)

>ffprobe h264-50i_mp2.ts -show_entries stream=duration -of flat
Before patch:
  streams.stream.0.duration="2.06"
  streams.stream.1.duration="1.176000"
After patch:
  streams.stream.0.duration="2.08"
  streams.stream.1.duration="1.20"


v2
v1: There was an issue with teletext where resolution is set just once at 
decoder init (teletext resolution is fixed/hard coded), so it is somewhat 
fragile: when a demuxer context update occurs, it is lost/overriden by 
avcodec_parameters_to_context(sti->avctx, st->codecpar) in read_frame_internal.
They could have been other scenario besides teletext, I don't know.
v2: So now at estimate_timings_from_pts, with one or more seeking involved 
(seeking is detected by the mpegts demuxer and set last_vn=-1, so pmt is 
forced/updated and results in demuxer context update), it is required to 
preserve the info in codecpar at first.
Thanks to Michael for reporting the issue.


Nicolas Gaullier (1):
  avformat/demux: Fix accurate probing of durations in mpegts/ps

 libavformat/demux.c   |  36 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 170 +-
 tests/ref/fate/ts-opus-demux  |   4 +-
 3 files changed, 100 insertions(+), 110 deletions(-)

-- 
2.30.2

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

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/exr: Check for remaining bits in huf_unpack_enc_table()

2024-04-02 Thread Michael Niedermayer
On Mon, Apr 01, 2024 at 04:00:04AM +0200, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 67645/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_fuzzer-6308760977997824
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/exr.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

will apply patches 1+2

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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

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


Re: [FFmpeg-devel] [PATCH 6/6] avcodec/apedec: Use NABS to avoid undefined negation

2024-04-02 Thread Michael Niedermayer
On Mon, Apr 01, 2024 at 10:56:07PM +0200, Michael Niedermayer wrote:
> Fixes: negation of -2147483648 cannot be represented in type 'int32_t' (aka 
> 'int'); cast to an unsigned type to negate this value to itself
> Fixes: 
> 67738/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5444313212321792
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/apedec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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 5/6] avcodec/hevc_ps: --typo

2024-04-02 Thread Michael Niedermayer
On Tue, Apr 02, 2024 at 09:12:09AM -0300, James Almer wrote:
> On 4/1/2024 5:56 PM, Michael Niedermayer wrote:
> > Fixes: null pointer dereference
> > Fixes: 
> > 67737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4858162608930816
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >   libavcodec/hevc_ps.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> > index 38b3721a6d5..25f087ed754 100644
> > --- a/libavcodec/hevc_ps.c
> > +++ b/libavcodec/hevc_ps.c
> > @@ -460,7 +460,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, 
> > AVCodecContext *avctx,
> >   int ret = AVERROR_INVALIDDATA;
> >   HEVCVPS *vps;
> > -if (ps->pps_list[vps_id]) {
> > +if (ps->vps_list[vps_id]) {
> >   const HEVCVPS *vps1 = ps->vps_list[vps_id];
> >   if (vps1->data_size == nal_size &&
> >   !memcmp(vps1->data, gb->buffer, vps1->data_size))
> 
> LGTM.

will apply

thx

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

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
than the original author, trying to rewrite it will not make it better.


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] lavc/vaapi_hevc: Add support for Main Intra & Main 10 Intra

2024-04-02 Thread Mark Thompson

On 02/04/2024 07:55, Xiang, Haihao wrote:

On Ma, 2024-04-01 at 21:11 +0100, Mark Thompson wrote:

On 28/03/2024 02:07, Xiang, Haihao wrote:

From: Haihao Xiang 

Both Main Intra and Main 10 Intra are Rext, we may use Main and Main 10
instead for decoding. This patch fixes the error below:

[hevc @ 0x55a771b80a00] No support for codec hevc profile 4.
[hevc @ 0x55a771b80a00] Failed setup for format vaapi: hwaccel
initialisation returned error.

Signed-off-by: Haihao Xiang 
---
   libavcodec/vaapi_hevc.c | 7 +++
   1 file changed, 7 insertions(+)

diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 3bdd2dd1b8..83b94d1a55 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -612,6 +612,13 @@ VAProfile
ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
   av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n",
profile->name);
   }
   
+#if VA_CHECK_VERSION(0, 37, 0)

+    if (!strcmp(profile->name, "Main Intra"))
+    return VAProfileHEVCMain;
+    else if (!strcmp(profile->name, "Main 10 Intra"))
+    return VAProfileHEVCMain10;
+#endif
+
   #if VA_CHECK_VERSION(1, 2, 0)
   if (!strcmp(profile->name, "Main 12") ||
   !strcmp(profile->name, "Main 12 Intra"))


What if high_precision_offsets_enabled_flag is set?

(That doesn't matter for the VAAPI encoder setting the profile because we
always have it as zero.)


Here use VAProfileHEVCMain or VAProfileHEVCMain10 to create VAConfig for
decoding,  avctx->profile (4) is not changed.
high_precision_offsets_enabled_flag is set in VAPictureParameterBufferHEVCRext
when avctx->profile is 4.


But Main and Main 10 profile have:

"Active SPSs for the base layer shall have ... high_precision_offsets_enabled_flag, 
... when present, equal to 0 only."

so a decoder implementing those profiles need not support it.  (It may work as 
a compatible extension as the field is there, but if it doesn't also support 
general rext cases then this is unlikely to be implemented.)

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/mfenc: expose more properties of the media foundation encoder

2024-04-02 Thread Mark Thompson

On 01/04/2024 19:55, Mark Thompson wrote:

On 01/04/2024 17:25, Mark Samuelson wrote:

On Mon, Apr 1, 2024 at 10:06 AM Mark Thompson  wrote:


On 28/03/2024 12:34, Mark Samuelson wrote:

Thank you for the notes, here is a new patch that incorporates your

suggestions.  You are right, the default value of 12 for gop_size is
suprising, I didn't know about it before now.


---
   libavcodec/mf_utils.h |  5 +
   libavcodec/mfenc.c    | 33 +++--
   2 files changed, 32 insertions(+), 6 deletions(-)


Patch looks good.

I did a bit of testing with the Microsoft H.264 MFT: GOP size and

compression level work as expected, and VBV parameters seem to be doing
something sensible.


Under what conditions are you expecting global_quality ->

AVEncVideoEncodeQP to do anything, though?  When I set it alone the output
was always identical regardless of what value I set > it to.  (Including
with "-rate_control quality".)


Thanks,

- Mark




I have also had issues making the Media Foundation encoder respect that
value.  I put it in there so that I could easily test it, because I was
having issues with the existing opt_enc_quality -> AVEncCommonQuality.  I
figured it was better to leave it in so people can experiment with it.


Fair, these options are not particularly consistent between different encoder 
MFT implementations.

I will apply this patch tomorrow unless there are any more comments on it.


Applied.

(git hint for emails: write email commentary below the "---" line - everything 
above that ends up in the commit message.  I edited this out of the patch.)

Thanks,

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/vvcdec: move vvcdec.{c, h} to the top directory

2024-04-02 Thread James Almer

On 4/2/2024 4:25 PM, Andreas Rheinhardt wrote:

James Almer:

As it's the main file declaring the AVCodec.


And why is that supposed to be an advantage?


It's not, it's a cosmetic change. Makes it easier to find at least one 
file containing the core code in the base directory.
And I'd like to do the same for other big modules with 3+ source files. 
hevc, h264, vp9, etc.

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/vvcdec: move vvcdec.{c, h} to the top directory

2024-04-02 Thread Andreas Rheinhardt
James Almer:
> As it's the main file declaring the AVCodec.

And why is that supposed to be an advantage?

- 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 v11 0/6] RCWT Closed Captions demuxer (v11)

2024-04-02 Thread Marth64
Thank you Stefano & all who helped facilitate this through.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] avcodec/vvcdec: move vvcdec.{c, h} to the top directory

2024-04-02 Thread James Almer
As it's the main file declaring the AVCodec.

Signed-off-by: James Almer 
---
 libavcodec/Makefile  |  1 +
 libavcodec/vvc/Makefile  |  3 +--
 libavcodec/vvc/vvc_ctu.h |  2 +-
 libavcodec/vvc/vvc_filter.h  |  2 +-
 libavcodec/vvc/vvc_intra_utils.c |  2 +-
 libavcodec/vvc/vvc_ps.c  |  2 +-
 libavcodec/vvc/vvc_refs.h|  2 +-
 libavcodec/vvc/vvc_thread.h  |  2 +-
 libavcodec/vvc/vvcdsp_template.c |  2 +-
 libavcodec/{vvc => }/vvcdec.c|  8 
 libavcodec/{vvc => }/vvcdec.h| 10 +-
 libavcodec/x86/vvc/vvcdsp_init.c |  2 +-
 12 files changed, 19 insertions(+), 19 deletions(-)
 rename libavcodec/{vvc => }/vvcdec.c (99%)
 rename libavcodec/{vvc => }/vvcdec.h (98%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index eef936944d..1b79472f10 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -794,6 +794,7 @@ OBJS-$(CONFIG_VPLAYER_DECODER) += textdec.o ass.o
 OBJS-$(CONFIG_VP9_V4L2M2M_DECODER) += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o
 OBJS-$(CONFIG_VQC_DECODER) += vqcdec.o
+OBJS-$(CONFIG_VVC_DECODER) += vvcdec.o
 OBJS-$(CONFIG_WADY_DPCM_DECODER)   += dpcm.o
 OBJS-$(CONFIG_WAVARC_DECODER)  += wavarc.o
 OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o wavpackdata.o dsd.o
diff --git a/libavcodec/vvc/Makefile b/libavcodec/vvc/Makefile
index 2a0055d494..9c72f2d543 100644
--- a/libavcodec/vvc/Makefile
+++ b/libavcodec/vvc/Makefile
@@ -1,8 +1,7 @@
 clean::
$(RM) $(CLEANSUFFIXES:%=libavcodec/vvc/%)
 
-OBJS-$(CONFIG_VVC_DECODER)  +=  vvc/vvcdec.o\
-vvc/vvcdsp.o\
+OBJS-$(CONFIG_VVC_DECODER)  +=  vvc/vvcdsp.o\
 vvc/vvc_cabac.o \
 vvc/vvc_ctu.o   \
 vvc/vvc_data.o  \
diff --git a/libavcodec/vvc/vvc_ctu.h b/libavcodec/vvc/vvc_ctu.h
index 460dbdba59..82ee033a70 100644
--- a/libavcodec/vvc/vvc_ctu.h
+++ b/libavcodec/vvc/vvc_ctu.h
@@ -26,7 +26,7 @@
 #include "libavcodec/cabac.h"
 #include "libavutil/mem_internal.h"
 
-#include "vvcdec.h"
+#include "libavcodec/vvcdec.h"
 
 #define MAX_CTU_SIZE128
 
diff --git a/libavcodec/vvc/vvc_filter.h b/libavcodec/vvc/vvc_filter.h
index 9597437d83..0df5e1250d 100644
--- a/libavcodec/vvc/vvc_filter.h
+++ b/libavcodec/vvc/vvc_filter.h
@@ -23,7 +23,7 @@
 #ifndef AVCODEC_VVC_VVC_FILTER_H
 #define AVCODEC_VVC_VVC_FILTER_H
 
-#include "vvcdec.h"
+#include "libavcodec/vvcdec.h"
 
 /**
  * lmcs filter for the CTU
diff --git a/libavcodec/vvc/vvc_intra_utils.c b/libavcodec/vvc/vvc_intra_utils.c
index 7d34cff023..0cc21f99bb 100644
--- a/libavcodec/vvc/vvc_intra_utils.c
+++ b/libavcodec/vvc/vvc_intra_utils.c
@@ -25,10 +25,10 @@
 #include "libavutil/avassert.h"
 #include "libavutil/macros.h"
 #include "libavutil/common.h"
+#include "libavcodec/vvcdec.h"
 #include "vvc_ctu.h"
 #include "vvc_intra.h"
 #include "vvc_ps.h"
-#include "vvcdec.h"
 
 int ff_vvc_get_mip_size_id(const int w, const int h)
 {
diff --git a/libavcodec/vvc/vvc_ps.c b/libavcodec/vvc/vvc_ps.c
index 301fa16400..8560c72c2e 100644
--- a/libavcodec/vvc/vvc_ps.c
+++ b/libavcodec/vvc/vvc_ps.c
@@ -25,9 +25,9 @@
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
 #include "libavcodec/refstruct.h"
+#include "libavcodec/vvcdec.h"
 #include "vvc_data.h"
 #include "vvc_ps.h"
-#include "vvcdec.h"
 
 static int sps_map_pixel_format(VVCSPS *sps, void *log_ctx)
 {
diff --git a/libavcodec/vvc/vvc_refs.h b/libavcodec/vvc/vvc_refs.h
index eba4422fb4..6d2c6d9107 100644
--- a/libavcodec/vvc/vvc_refs.h
+++ b/libavcodec/vvc/vvc_refs.h
@@ -23,7 +23,7 @@
 #ifndef AVCODEC_VVC_VVC_REFS_H
 #define AVCODEC_VVC_VVC_REFS_H
 
-#include "vvcdec.h"
+#include "libavcodec/vvcdec.h"
 
 int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, struct AVFrame 
*out, int no_output_of_prior_pics_flag, int flush);
 void ff_vvc_bump_frame(VVCContext *s, VVCFrameContext *fc);
diff --git a/libavcodec/vvc/vvc_thread.h b/libavcodec/vvc/vvc_thread.h
index 6c726744f8..29c56b9aa0 100644
--- a/libavcodec/vvc/vvc_thread.h
+++ b/libavcodec/vvc/vvc_thread.h
@@ -23,7 +23,7 @@
 #ifndef AVCODEC_VVC_VVC_THREAD_H
 #define AVCODEC_VVC_VVC_THREAD_H
 
-#include "vvcdec.h"
+#include "libavcodec/vvcdec.h"
 
 struct AVExecutor* ff_vvc_executor_alloc(VVCContext *s, int thread_count);
 void ff_vvc_executor_free(struct AVExecutor **e);
diff --git a/libavcodec/vvc/vvcdsp_template.c b/libavcodec/vvc/vvcdsp_template.c
index 33815d6765..ac0107740d 100644
--- a/libavcodec/vvc/vvcdsp_template.c
+++ b/libavcodec/vvc/vvcdsp_template.c
@@ -21,8 +21,8 @@
  */
 #include "libavutil/frame.h"
 #include "libavcodec/bit_depth_template.c"
+#include "libavcodec/vvcdec.h"
 
-#include "vvcdec.h"
 #include "vvc_data.h"
 
 #include "vvc_inter_template.c"
diff --git a/libavcodec/vvc/vvcdec.c 

Re: [FFmpeg-devel] [PATCH 01/10] avcodec/libvpxenc: Avoid unused-variable warning if VP9 enc is disabled

2024-04-02 Thread James Zern via ffmpeg-devel
On Mon, Apr 1, 2024 at 11:29 AM Andreas Rheinhardt
 wrote:
>
> James Zern via ffmpeg-devel:
> > On Sat, Mar 30, 2024 at 10:30 PM Andreas Rheinhardt
> >  wrote:
> >>
> >> Signed-off-by: Andreas Rheinhardt 
> >> ---
> >>  libavcodec/libvpxenc.c | 7 ---
> >>  1 file changed, 4 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> >> index 635cdf7a0e..bcbdc4981e 100644
> >> --- a/libavcodec/libvpxenc.c
> >> +++ b/libavcodec/libvpxenc.c
> >> @@ -49,6 +49,9 @@
> >>  #include "libavutil/opt.h"
> >>  #include "libavutil/pixdesc.h"
> >>
> >> +#define IS_VP9(avctx) (CONFIG_LIBVPX_VP9_ENCODER && avctx->codec_id == 
> >> AV_CODEC_ID_VP9)
> >> +#define IS_VP8(avctx) (CONFIG_LIBVPX_VP8_ENCODER && avctx->codec_id == 
> >> AV_CODEC_ID_VP8)
> >> +
> >>  /**
> >>   * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
> >>   * One encoded frame returned from the library.
> >> @@ -359,8 +362,7 @@ static int frame_data_submit(AVCodecContext *avctx, 
> >> AVFifo *fifo,
> >>  FrameData fd = { .pts = frame->pts };
> >>  int ret;
> >>
> >> -#if CONFIG_LIBVPX_VP9_ENCODER
> >> -if (avctx->codec_id == AV_CODEC_ID_VP9 &&
> >> +if (IS_VP9(avctx) &&
> >
> > This works and I think the style is largely prevalent in other code.
> > Given the current structure you could move the enccfg declaration to
> > this block as an alternative.
>
> The latter would entail either opening a new block for the #if part or
> hoping (due to -Wdeclaration-after-statement) that this #if block stays
> at the start of this function. I prefer my approach above to either of
> these alternatives (a third alternative would be to avoid the enccfg
> variable altogether and to check ctx->encoder.config.enc->g_bit_depth
> instead; another alternative is av_unused). Just tell me which
> alternative you prefer.
>

I only made the comment because I didn't think it would need a new
block as it is, but you're right, code moves around. This is fine and
simpler than having a debate about the warning given the adoption of
other C99/C11 features.
___
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 v11 0/6] RCWT Closed Captions demuxer (v11)

2024-04-02 Thread Stefano Sabatini
On date Tuesday 2024-04-02 00:24:52 -0500, Marth64 wrote:
> Since v9:
> * Removes .bin extension association in demuxer and muxer
> * Updates examples in documentation

Patchset applied, thanks.

I also added the missing Changelog next entrypoint and updated the
Changelog with the new entry while at it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/4] avutil/pix{desc, fmt}: add new matrix coefficients from H.273 v3

2024-04-02 Thread Jan Ekström
On Mon, Apr 1, 2024 at 2:34 PM Jan Ekström  wrote:
>
> On Fri, Mar 29, 2024 at 8:32 PM Jan Ekström  wrote:
> >
> > On Fri, Mar 29, 2024 at 2:33 AM Jan Ekström  wrote:
> > >
> > > * SMPTE ST 2128 IPT-C2 defines the coefficients utilized in DoVi
> > >   Profile 5. Profile 5 can thus now be represented in VUI as
> > >   {AVCOL_RANGE_JPEG, AVCOL_PRI_BT2020, AVCOL_TRC_SMPTE2084,
> > >AVCOL_SPC_IPT_C2, AVCHROMA_LOC_LEFT} (although other chroma
> > >   sample locations are allowed). AVCOL_TRC_SMPTE2084 should in
> > >   this case be interpreted as 'PQ with reshaping'.
> > > * YCgCo-Re and YCgCo-Ro define the bitexact YCgCo-R, where the
> > >   number of bits added to a source RGB bit depth is 2 (i.e., even)
> > >   and 1 (i.e., odd), respectively.
> > > ---
> > >  doc/APIchanges  | 4 
> > >  libavutil/pixdesc.c | 3 +++
> > >  libavutil/pixfmt.h  | 3 +++
> > >  libavutil/version.h | 2 +-
> > >  4 files changed, 11 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/doc/APIchanges b/doc/APIchanges
> > > index aa102b4925..296d87d8fb 100644
> > > --- a/doc/APIchanges
> > > +++ b/doc/APIchanges
> > > @@ -2,6 +2,10 @@ The last version increases of all libraries were on 
> > > 2024-03-07
> > >
> > >  API changes, most recent first:
> > >
> > > +2024-03-27 - xx - lavu 59.11.100 - pixfmt.h
> > > +  Add AVCOL_SPC_IPT_C2, AVCOL_SPC_YCGCO_RE and AVCOL_SPC_YCGCO_RO
> > > +  to map new matrix coefficients defined by H.273 v3.
> > > +
> > >  2024-03-27 - xx - lavu 59.10.100 - frame.h
> > >Add AVSideDataDescriptor, enum AVSideDataProps, and
> > >av_frame_side_data_desc().
> > > diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
> > > index 9c708520b1..1c0bcf2232 100644
> > > --- a/libavutil/pixdesc.c
> > > +++ b/libavutil/pixdesc.c
> > > @@ -2854,6 +2854,9 @@ static const char * const color_space_names[] = {
> > >  [AVCOL_SPC_CHROMA_DERIVED_NCL] = "chroma-derived-nc",
> > >  [AVCOL_SPC_CHROMA_DERIVED_CL] = "chroma-derived-c",
> > >  [AVCOL_SPC_ICTCP] = "ictcp",
> > > +[AVCOL_SPC_IPT_C2] = "ipt-c2",
> > > +[AVCOL_SPC_YCGCO_RE] = "ycgco-re",
> > > +[AVCOL_SPC_YCGCO_RO] = "ycgco-ro",
> > >  };
> > >
> > >  static const char * const chroma_location_names[] = {
> > > diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
> > > index 4aa20e4e58..430118d3e1 100644
> > > --- a/libavutil/pixfmt.h
> > > +++ b/libavutil/pixfmt.h
> > > @@ -623,6 +623,9 @@ enum AVColorSpace {
> > >  AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived 
> > > non-constant luminance system
> > >  AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant 
> > > luminance system
> > >  AVCOL_SPC_ICTCP   = 14, ///< ITU-R BT.2100-0, ICtCp
> > > +AVCOL_SPC_IPT_C2  = 15, ///< SMPTE ST 2128
> > > +AVCOL_SPC_YCGCO_RE= 16, ///< YCgCo-R, even addition of bits
> > > +AVCOL_SPC_YCGCO_RO= 17, ///< YCgCo-R, odd addition of bits
> > >  AVCOL_SPC_NB///< Not part of ABI
> > >  };
> >
> > To aid in review as for whatever reason the 2023-09 H.273 v3 is not
> > yet publicly available (even though H.274 is from the same September
> > period), you can first of all see the summary in
> > https://www.itu.int/itu-t/workprog/wp_item.aspx?isn=18689 .
> >
> > The latest related drafts from JVET-Experts
> > (https://jvet-experts.org/doc_end_user/all_meeting.php being the
> > index) are:
> > - CICP/H.273: JVET-AD1003 v2 from
> > https://jvet-experts.org/doc_end_user/current_document.php?id=12970
> > - H.265: JVET-AF1006 from
> > https://jvet-experts.org/doc_end_user/current_document.php?id=13584
> > - H.264: JVET-AE1016 from
> > https://jvet-experts.org/doc_end_user/current_document.php?id=13269
> >
> > Given that H.273 v3 got registered for AAP on 2023-07-21 and that the
> > H.265 text is clearly from after the last call period of 2023-09-01 to
> > 2023-09-28, I would consider them all matching being a pretty good
> > indicator that the value 15 got utilized for IPT-C2, and 16+17 for
> > YCgCo-R.
>
> Ping for this set.

Got an LGTM from James for the set on IRC, so unless there are
objections I will apply this tomorrow.

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

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/liblc3: Add encoding/decoding support of LC3 audio codec

2024-04-02 Thread Stefano Sabatini
On date Friday 2024-03-29 17:30:30 +, ffmpeg-devel Mailing List wrote:
> The LC3 audio codec is the default codec of Bluetooth LE audio.
> This is a wrapper over the liblc3 library (https://github.com/google/liblc3).
> 
> Signed-off-by: Antoine Soulier 
> ---
>  Changelog |   4 +
>  configure |   6 ++
>  doc/encoders.texi |  57 
>  doc/general_contents.texi |  11 ++-
>  libavcodec/Makefile   |   2 +
>  libavcodec/allcodecs.c|   2 +
>  libavcodec/codec_desc.c   |   7 ++
>  libavcodec/codec_id.h |   1 +
>  libavcodec/liblc3dec.c| 141 
>  libavcodec/liblc3enc.c| 190 ++
>  10 files changed, 420 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/liblc3dec.c
>  create mode 100644 libavcodec/liblc3enc.c

I don't see pending comments for this patch, so I'll apply it in
one/two days if I see no more comments.

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

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


Re: [FFmpeg-devel] [PATCH v6] avformat/demux: Add duration_probesize AVOption

2024-04-02 Thread Stefano Sabatini
On date Friday 2024-03-29 11:00:28 +0100, Stefano Sabatini wrote:
> On date Friday 2024-03-29 10:26:19 +0100, Nicolas Gaullier wrote:
> > Yet another probesize used to get the durations when
> > estimate_timings_from_pts is required. It is aimed at users interested
> > in better durations probing for itself, or because using
> > avformat_find_stream_info indirectly and requiring exact values: for
> > concatdec for example, especially if streamcopying above it.
> > The current code is a performance trade-off that can fail to get video
> > stream durations in a scenario with high bitrates and buffering for
> > files ending cleanly (as opposed to live captures): the physical gap
> > between the last video packet and the last audio packet is very high in
> > such a case.
> > 
> > Default behaviour is unchanged: 250k up to 250k << 6 (step by step).
> > Setting this new option has two effects:
> > - override the maximum probesize (currently 250k << 6)
> > - reduce the number of steps to 1 instead of 6, this is to avoid
> > detecting the audio "too early" and failing to reach a video packet.
> > Even if a single audio stream duration is found but not the other
> > audio/video stream durations, there will be a retry, so at the end the
> > full user-overriden probesize will be used as expected by the user.
> > 
> > Signed-off-by: Nicolas Gaullier 
> > ---
> >  doc/APIchanges  |  3 +++
> >  doc/formats.texi| 19 ++-
> >  libavformat/avformat.h  | 16 ++--
> >  libavformat/demux.c | 13 -
> >  libavformat/options_table.h |  1 +
> >  libavformat/version.h   |  2 +-
> >  6 files changed, 45 insertions(+), 9 deletions(-)
> 
> Looks good to me, will apply in a few days if there are no further
> comments.

Will apply soon, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] 7.0 Name

2024-04-02 Thread Andreas Rheinhardt
Vittorio Giovara:
> Dijkstra time!
> 
> On Tue, Apr 2, 2024 at 11:22 AM  wrote:
> 
>> My choice would be Dijkstra as well.
>>
>> On 2 Apr 2024, at 7:45, AV Preservation by reto.ch (lists) wrote:
>>
>>> Sean McGovern wrote:
>>>
 Not sure if I am allowed to pick, my choice is Dijkstra.
>>>
>>> When I started programming in 1975, Edsger W. Dijkstra was one of my
>> heroes, which is why I support your proposal, even though I am not an
>> FFmpeg developer.
>>>
>>> Best regards, Reto

+1

- 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] 7.0 Name

2024-04-02 Thread Vittorio Giovara
Dijkstra time!

On Tue, Apr 2, 2024 at 11:22 AM  wrote:

> My choice would be Dijkstra as well.
>
> On 2 Apr 2024, at 7:45, AV Preservation by reto.ch (lists) wrote:
>
> > Sean McGovern wrote:
> >
> >> Not sure if I am allowed to pick, my choice is Dijkstra.
> >
> > When I started programming in 1975, Edsger W. Dijkstra was one of my
> heroes, which is why I support your proposal, even though I am not an
> FFmpeg developer.
> >
> > Best regards, Reto
> > ___
> > 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".
>


-- 
Vittorio
___
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 00/16] avcodec/vvcdec: support subpicture

2024-04-02 Thread James Almer

On 4/2/2024 10:01 AM, Nuo Mi wrote:

On Wed, Mar 27, 2024 at 9:01 PM Nuo Mi  wrote:


Changes since v1:
add v2-0004-avcodec-vvcdec-fix-uninitialized-last-element-of-.patch to
address
the clang-usan and clang-asan failures reported by Frank



pushed.


I added a test for this using SUBPIC_C_ERICSSON_1.bit
Also, i disabled the tests for OPI_B_3.bit and VPS_A_3.bit as they rely 
on a non-implemented feature. And while they still output a frame or two 
as is, it's not the case on all systems.


There's not a lot of VVC bitstreams currently in the FATE suite, so if 
you know of any that will increase the coverage (See for example 
http://coverage.ffmpeg.org/index.vvc_intra.c.5d0b519a39871515a1754ee8847b6d69.html#l678, 
where vvc_predict_ibc() is never run), then please make a test for it 
and I'll upload the sample.

___
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] 7.0 Name

2024-04-02 Thread epirat07
My choice would be Dijkstra as well.

On 2 Apr 2024, at 7:45, AV Preservation by reto.ch (lists) wrote:

> Sean McGovern wrote:
>
>> Not sure if I am allowed to pick, my choice is Dijkstra.
>
> When I started programming in 1975, Edsger W. Dijkstra was one of my heroes, 
> which is why I support your proposal, even though I am not an FFmpeg 
> developer.
>
> Best regards, Reto
> ___
> 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] 7.0 Name

2024-04-02 Thread Marth64
Djikstra is nice
___
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] libavformat/libsrt.c: Add statistics option to output SRT statistics with av_log()

2024-04-02 Thread Zhao Zhili

> 在 2024年3月19日,下午7:51,Ryan McCartney  写道:
> 
> ---
> libavformat/libsrt.c | 37 +
> 1 file changed, 37 insertions(+)
> 
> diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c
> index a7aafea536..80d52b1737 100644
> --- a/libavformat/libsrt.c
> +++ b/libavformat/libsrt.c
> @@ -56,6 +56,8 @@ typedef struct SRTContext {
> int eid;
> int64_t rw_timeout;
> int64_t listen_timeout;
> +int64_t lastStatsTime;
> +int64_t stats;
> int recv_buffer_size;
> int send_buffer_size;
> 
> @@ -100,6 +102,7 @@ typedef struct SRTContext {
> static const AVOption libsrt_options[] = {
> { "timeout","Timeout of socket I/O operations (in microseconds)", 
>   OFFSET(rw_timeout),   AV_OPT_TYPE_INT64, { .i64 = -1 }, 
> -1, INT64_MAX, .flags = D|E },
> { "listen_timeout", "Connection awaiting timeout (in microseconds)" , 
>   OFFSET(listen_timeout),   AV_OPT_TYPE_INT64, { .i64 = -1 }, 
> -1, INT64_MAX, .flags = D|E },
> +{ "stats",  "Show SRT statistics in the log output", 
>OFFSET(stats),AV_OPT_TYPE_INT64, { .i64 = -1 
> }, -1, INT64_MAX, .flags = D|E },  
> { "send_buffer_size", "Socket send buffer size (in bytes)",   
>   OFFSET(send_buffer_size), AV_OPT_TYPE_INT,  { .i64 = -1 
> }, -1, INT_MAX,   .flags = D|E },
> { "recv_buffer_size", "Socket receive buffer size (in bytes)",
>   OFFSET(recv_buffer_size), AV_OPT_TYPE_INT,  { .i64 = -1 
> }, -1, INT_MAX,   .flags = D|E },
> { "pkt_size",   "Maximum SRT packet size",
>   OFFSET(payload_size), AV_OPT_TYPE_INT,  { .i64 = -1 
> }, -1, SRT_LIVE_MAX_PAYLOAD_SIZE, .flags = D|E, .unit = "payload_size" },
> @@ -158,6 +161,29 @@ static int libsrt_neterrno(URLContext *h)
> return os_errno ? AVERROR(os_errno) : AVERROR_UNKNOWN;
> }
> 
> +static int libsrt_stats(URLContext *h,int read)
> +{   
> +SRTContext *s = h->priv_data;
> +SRT_TRACEBSTATS trace;
> +
> +int ret = srt_bistats(s->fd, , 0,1);
> +int64_t timeNow = trace.msTimeStamp;
> +int64_t timeNext = s->lastStatsTime + s->stats;
> +
> +if((ret >= 0) && (timeNow > timeNext )){
> +s->lastStatsTime = timeNow;
> +
> +if(read > 0){
> +av_log(h, AV_LOG_INFO, "[srt-stats] rate=%.2fMbps bw=%.2fMbps 
> rtt=%.2fms total=%jdpkts retrans=%jdpkts loss=%jdpkts \n", 
> trace.mbpsRecvRate,trace.mbpsBandwidth,trace.msRTT,trace.pktRecvTotal,trace.pktRcvRetrans,trace.pktRcvLossTotal);
> +}
> +else{
> +av_log(h, AV_LOG_INFO, "[srt-stats] rate=%.2fMbps bw=%.2fMbps 
> rtt=%.2fms total=%jdpkts retrans=%jdpkts loss=%jdpkts \n", 
> trace.mbpsSendRate,trace.mbpsBandwidth,trace.msRTT,trace.pktSentTotal,trace.pktRetrans,trace.pktSndLossTotal);
> +}
> +}
> +
> +return 0;
> +}

The implementation is simple but not flexible enough. We need more than print. 
I have this issue on my mind but don’t figure out a solution yet.

> +
> static int libsrt_getsockopt(URLContext *h, int fd, SRT_SOCKOPT optname, 
> const char * optnamestr, void * optval, int * optlen)
> {
> if (srt_getsockopt(fd, 0, optname, optval, optlen) < 0) {
> @@ -557,6 +583,9 @@ static int libsrt_open(URLContext *h, const char *uri, 
> int flags)
> goto err;
> }
> }
> +if (av_find_info_tag(buf, sizeof(buf), "stats", p)) {
> +s->stats = strtol(buf, NULL, 10);
> +}
> #if SRT_VERSION_VALUE >= 0x010302
> if (av_find_info_tag(buf, sizeof(buf), "enforced_encryption", p)) {
> s->enforced_encryption = strtol(buf, NULL, 10);
> @@ -686,6 +715,10 @@ static int libsrt_read(URLContext *h, uint8_t *buf, int 
> size)
> SRTContext *s = h->priv_data;
> int ret;
> 
> +if(s->stats > 0){
> +libsrt_stats(h,1);
> +}
> +
> if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
> ret = libsrt_network_wait_fd_timeout(h, s->eid, 0, h->rw_timeout, 
> >interrupt_callback);
> if (ret)
> @@ -705,6 +738,10 @@ static int libsrt_write(URLContext *h, const uint8_t 
> *buf, int size)
> SRTContext *s = h->priv_data;
> int ret;
> 
> +if(s->stats > 0){
> +libsrt_stats(h,0);
> +}
> +
> if (!(h->flags & AVIO_FLAG_NONBLOCK)) {
> ret = libsrt_network_wait_fd_timeout(h, s->eid, 1, h->rw_timeout, 
> >interrupt_callback);
> if (ret)
> -- 
> 2.43.0
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email

___
ffmpeg-devel 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 

[FFmpeg-devel] [PATCH v3 2/2] avfilter/vf_colorspace: Use colorspace negotiation API

2024-04-02 Thread Nicolas Gaullier
Fixes a regression due to the fact that the colorspace filter does
not use the new API introduced by 8c7934f73ab6c568acaa.
The scale filter uses it since 45e09a30419cc2a7251e, and the setparams
filter since 3bf80df3ccd32aed23f0.

Example 1 - color_range specified:
ffmpeg -f lavfi -i yuvtestsrc -vf setparams=color_primaries=bt470bg:
color_trc=smpte170m:colorspace=bt470bg,colorspace=bt709:range=tv,scale
,showinfo -f null -frames 1 -

Before:
  color_range:unknown color_space:bt470bg ...
After:
  color_range:tv color_space:bt709 ...

Example 2 - color_range pass-through:
ffmpeg -f lavfi -i yuvtestsrc -vf "setparams=color_primaries=bt470bg:
color_trc=smpte170m:colorspace=bt470bg:range=unknown,
setparams=range=pc:enable='between(n,1,2)',
setparams=range=tv:enable='between(n,2,3)',
colorspace=bt709,scale,showinfo"
-f null -frames 3 - 2>&1|awk "/color_/ {print \$4 \" \" \$5}"

Before:
color_range:tv color_space:bt470bg
color_range:tv color_space:bt470bg
color_range:tv color_space:bt470bg
After:
color_range:unknown color_space:bt709
color_range:pc color_space:bt709
color_range:tv color_space:bt709

Signed-off-by: Nicolas Gaullier 
---
 libavfilter/vf_colorspace.c | 63 +
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index d181e81ace..12a571172b 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -433,8 +433,7 @@ static int create_filtergraph(AVFilterContext *ctx,
 if (out->color_trc   != s->out_trc) s->out_txchr = NULL;
 if (in->colorspace   != s->in_csp ||
 in->color_range  != s->in_rng)  s->in_lumacoef   = NULL;
-if (out->colorspace  != s->out_csp ||
-out->color_range != s->out_rng) s->out_lumacoef  = NULL;
+if (out->color_range != s->out_rng) s->rgb2yuv   = NULL;
 
 if (!s->out_primaries || !s->in_primaries) {
 s->in_prm = in->color_primaries;
@@ -563,26 +562,8 @@ static int create_filtergraph(AVFilterContext *ctx,
 redo_yuv2rgb = 1;
 }
 
-if (!s->out_lumacoef) {
-s->out_csp = out->colorspace;
+if (!s->rgb2yuv) {
 s->out_rng = out->color_range;
-s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
-if (!s->out_lumacoef) {
-if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
-if (s->user_all == CS_UNSPECIFIED) {
-av_log(ctx, AV_LOG_ERROR,
-   "Please specify output colorspace\n");
-} else {
-av_log(ctx, AV_LOG_ERROR,
-   "Unsupported output color property %d\n", 
s->user_all);
-}
-} else {
-av_log(ctx, AV_LOG_ERROR,
-   "Unsupported output colorspace %d (%s)\n", s->out_csp,
-   av_color_space_name(s->out_csp));
-}
-return AVERROR(EINVAL);
-}
 redo_rgb2yuv = 1;
 }
 
@@ -687,6 +668,26 @@ static av_cold int init(AVFilterContext *ctx)
 {
 ColorSpaceContext *s = ctx->priv;
 
+s->out_csp  = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
+  default_csp[FFMIN(s->user_all, CS_NB)] : s->user_csp;
+s->out_lumacoef = av_csp_luma_coeffs_from_avcsp(s->out_csp);
+if (!s->out_lumacoef) {
+if (s->out_csp == AVCOL_SPC_UNSPECIFIED) {
+if (s->user_all == CS_UNSPECIFIED) {
+av_log(ctx, AV_LOG_ERROR,
+   "Please specify output colorspace\n");
+} else {
+av_log(ctx, AV_LOG_ERROR,
+   "Unsupported output color property %d\n", s->user_all);
+}
+} else {
+av_log(ctx, AV_LOG_ERROR,
+   "Unsupported output colorspace %d (%s)\n", s->out_csp,
+   av_color_space_name(s->out_csp));
+}
+return AVERROR(EINVAL);
+}
+
 ff_colorspacedsp_init(>dsp);
 
 return 0;
@@ -735,6 +736,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 return res;
 }
 
+out->colorspace = s->out_csp;
+outlink->color_range = s->user_rng != AVCOL_RANGE_UNSPECIFIED ? 
s->user_rng : in->color_range;
+out->color_range = outlink->color_range;
 out->color_primaries = s->user_prm == AVCOL_PRI_UNSPECIFIED ?
default_prm[FFMIN(s->user_all, CS_NB)] : 
s->user_prm;
 if (s->user_trc == AVCOL_TRC_UNSPECIFIED) {
@@ -746,10 +750,6 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 } else {
 out->color_trc   = s->user_trc;
 }
-out->colorspace  = s->user_csp == AVCOL_SPC_UNSPECIFIED ?
-   default_csp[FFMIN(s->user_all, CS_NB)] : 
s->user_csp;
-out->color_range = s->user_rng == AVCOL_RANGE_UNSPECIFIED ?
-   in->color_range : s->user_rng;
 if (rgb_sz != s->rgb_sz) {
 const AVPixFmtDescriptor 

[FFmpeg-devel] [PATCH v3 1/2] avfilter/vf_setparams: Add timeline support

2024-04-02 Thread Nicolas Gaullier
This is helpful at least for test purposes.

Signed-off-by: Nicolas Gaullier 
---
 libavfilter/vf_setparams.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_setparams.c b/libavfilter/vf_setparams.c
index c96f4d314b..1b5eb70344 100644
--- a/libavfilter/vf_setparams.c
+++ b/libavfilter/vf_setparams.c
@@ -198,7 +198,7 @@ const AVFilter ff_vf_setparams = {
 .description = NULL_IF_CONFIG_SMALL("Force field, or color property for 
the output video frame."),
 .priv_size   = sizeof(SetParamsContext),
 .priv_class  = _class,
-.flags   = AVFILTER_FLAG_METADATA_ONLY,
+.flags   = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | 
AVFILTER_FLAG_METADATA_ONLY,
 FILTER_INPUTS(inputs),
 FILTER_OUTPUTS(ff_video_default_filterpad),
 FILTER_QUERY_FUNC(query_formats),
-- 
2.30.2

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

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


[FFmpeg-devel] [PATCH v3 0/2] avfilter/vf_colorspace: Use colorspace negotiation API

2024-04-02 Thread Nicolas Gaullier
v3:
- Fixes case where colorspace is the first filter (no inlink)
- Illustrates with proper examples in commit msg (use yuvtestsrc instead of 
testsrc)

Please note that it is a regression compared to the previous release:
both examples (see commit msg) behave the same way as 6.1 after this patch.


Nicolas Gaullier (2):
  avfilter/vf_setparams: Add timeline support
  avfilter/vf_colorspace: Use colorspace negotiation API

 libavfilter/vf_colorspace.c | 63 +
 libavfilter/vf_setparams.c  |  2 +-
 2 files changed, 37 insertions(+), 28 deletions(-)

-- 
2.30.2

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

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


Re: [FFmpeg-devel] [PATCH v2 00/16] avcodec/vvcdec: support subpicture

2024-04-02 Thread Nuo Mi
On Wed, Mar 27, 2024 at 9:01 PM Nuo Mi  wrote:

> Changes since v1:
> add v2-0004-avcodec-vvcdec-fix-uninitialized-last-element-of-.patch to
> address
> the clang-usan and clang-asan failures reported by Frank


pushed.
___
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 1/1] avcodec, avformat/ffjni: fix duplicate JNI symbols

2024-04-02 Thread Matthieu Bouron
On Mon, Apr 01, 2024 at 10:03:54AM +0200, Matthieu Bouron wrote:
> On Wed, Mar 27, 2024 at 09:06:19AM -0400, Leo Izen wrote:
> > Use SHLIBOBJS and STLIBOBJS in the Makefiles for avcodec and avformat,
> > and add a stub ffjni.c to libavformat, which allows the symbols to be
> > duplicated for shared builds but not static builds.
> > 
> > Signed-off-by: Leo Izen 
> > ---
> >  libavcodec/Makefile  |  1 +
> >  libavformat/Makefile |  1 +
> >  libavformat/ffjni.c  | 23 +++
> >  libavformat/file.c   |  2 +-
> >  4 files changed, 26 insertions(+), 1 deletion(-)
> >  create mode 100644 libavformat/ffjni.c
> > 
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index 9ce6d445c1..113adb22d5 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1068,6 +1068,7 @@ STLIBOBJS-$(CONFIG_ISO_MEDIA)  += 
> > mpegaudiotabs.o
> >  STLIBOBJS-$(CONFIG_FLV_MUXER)  += mpeg4audio_sample_rates.o
> >  STLIBOBJS-$(CONFIG_HLS_DEMUXER)+= ac3_channel_layout_tab.o
> >  STLIBOBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER) += jpegxl_parse.o
> > +STLIBOBJS-$(CONFIG_JNI)+= ffjni.o
> >  STLIBOBJS-$(CONFIG_JPEGXL_ANIM_DEMUXER)   += jpegxl_parse.o
> >  STLIBOBJS-$(CONFIG_MATROSKA_DEMUXER)   += mpeg4audio_sample_rates.o
> >  STLIBOBJS-$(CONFIG_MOV_DEMUXER)+= ac3_channel_layout_tab.o
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index 44aa485029..a89df7e9a3 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -728,6 +728,7 @@ SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= 
> > mpegaudiotabs.o
> >  SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o
> >  SHLIBOBJS-$(CONFIG_HLS_DEMUXER)  += ac3_channel_layout_tab.o
> >  SHLIBOBJS-$(CONFIG_IMAGE_JPEGXL_PIPE_DEMUXER)+= jpegxl_parse.o
> > +SHLIBOBJS-$(CONFIG_JNI)  += ffjni.o
> >  SHLIBOBJS-$(CONFIG_JPEGXL_ANIM_DEMUXER)  += jpegxl_parse.o
> >  SHLIBOBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio_sample_rates.o
> >  SHLIBOBJS-$(CONFIG_MOV_DEMUXER)  += ac3_channel_layout_tab.o
> > diff --git a/libavformat/ffjni.c b/libavformat/ffjni.c
> > new file mode 100644
> > index 00..2b1483cf42
> > --- /dev/null
> > +++ b/libavformat/ffjni.c
> > @@ -0,0 +1,23 @@
> > +/*
> > + * JNI utility functions - included stub
> > + *
> > + * Copyright (c) 2024 Leo Izen 
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
> > 02110-1301 USA
> > + */
> > +
> > +#include "libavcodec/ffjni.c"
> > diff --git a/libavformat/file.c b/libavformat/file.c
> > index 182995717a..1f853e0e17 100644
> > --- a/libavformat/file.c
> > +++ b/libavformat/file.c
> > @@ -527,8 +527,8 @@ const URLProtocol ff_fd_protocol = {
> >  
> >  #if CONFIG_ANDROID_CONTENT_PROTOCOL
> >  #include 
> > +#include "libavcodec/ffjni.h"
> >  #include "libavcodec/jni.h"
> > -#include "libavcodec/ffjni.c"
> >  
> >  typedef struct JFields {
> >  jclass uri_class;
> 
> LGTM, thanks.

Once the patch is applied. Can you also backport it to the 7.0 branch ?

Thanks in advance,

-- 
Matthieu B.
___
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 v1 7/7] lavc/vaapi_dec: Add VVC decoder

2024-04-02 Thread Nuo Mi
On Thu, Mar 28, 2024 at 9:27 AM  wrote:

> From: Fei Wang 
>
> Signed-off-by: Fei Wang 
> ---
>  Changelog |   4 +
>  configure |   3 +
>  libavcodec/Makefile   |   1 +
>  libavcodec/hwaccels.h |   1 +
>  libavcodec/vaapi_decode.c |   7 +
>  libavcodec/vaapi_vvc.c| 657 ++
>  libavcodec/version.h  |   2 +-
>  libavcodec/vvc/vvcdec.c   |  15 +-
>  8 files changed, 688 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/vaapi_vvc.c
>
> diff --git a/Changelog b/Changelog
> index e83a00e35c..3108e65558 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -1,6 +1,10 @@
>  Entries are sorted chronologically from oldest to youngest within each
> release,
>  releases are sorted from youngest to oldest.
>
> +version :
> +- VVC VAAPI decoder
> +
> +
>  version 7.0:
>  - DXV DXT1 encoder
>  - LEAD MCMP decoder
> diff --git a/configure b/configure
> index 2a1d22310b..d902c9adc8 100755
> --- a/configure
> +++ b/configure
> @@ -3258,6 +3258,8 @@ vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9"
>  vp9_vdpau_hwaccel_select="vp9_decoder"
>  vp9_videotoolbox_hwaccel_deps="videotoolbox"
>  vp9_videotoolbox_hwaccel_select="vp9_decoder"
> +vvc_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVVC"
> +vvc_vaapi_hwaccel_select="vvc_decoder"
>  wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel"
>  wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel"
>  wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel"
> @@ -7250,6 +7252,7 @@ if enabled vaapi; then
>  check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)"
>
>  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> +check_type "va/va.h va/va_dec_vvc.h" "VAPictureParameterBufferVVC"
>  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
>  check_struct "va/va.h" "VADecPictureParameterBufferAV1" bit_depth_idx
>  check_type   "va/va.h va/va_vpp.h"
> "VAProcFilterParameterBufferHDRToneMapping"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 9ce6d445c1..343b037636 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -1054,6 +1054,7 @@ OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  +=
> vaapi_vp9.o
>  OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
>  OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL)   += videotoolbox_vp9.o
>  OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
> +OBJS-$(CONFIG_VVC_VAAPI_HWACCEL)  += vaapi_vvc.o
>
>  # Objects duplicated from other libraries for shared builds
>  SHLIBOBJS  += log2_tab.o reverse.o
> diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h
> index 5171e4c7d7..88d6b9a9b5 100644
> --- a/libavcodec/hwaccels.h
> +++ b/libavcodec/hwaccels.h
> @@ -82,6 +82,7 @@ extern const struct FFHWAccel ff_vp9_nvdec_hwaccel;
>  extern const struct FFHWAccel ff_vp9_vaapi_hwaccel;
>  extern const struct FFHWAccel ff_vp9_vdpau_hwaccel;
>  extern const struct FFHWAccel ff_vp9_videotoolbox_hwaccel;
> +extern const struct FFHWAccel ff_vvc_vaapi_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d11va_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d11va2_hwaccel;
>  extern const struct FFHWAccel ff_wmv3_d3d12va_hwaccel;
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index 1b1972a2a9..ceeb1f1a12 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -455,6 +455,9 @@ static const struct {
>  MAP(AV1, AV1_MAIN,AV1Profile0),
>  MAP(AV1, AV1_HIGH,AV1Profile1),
>  #endif
> +#if VA_CHECK_VERSION(1, 22, 0)
> +MAP(H266,VVC_MAIN_10, VVCMain10),
> +#endif
>
>  #undef MAP
>  };
> @@ -627,6 +630,10 @@ static int vaapi_decode_make_config(AVCodecContext
> *avctx,
>  case AV_CODEC_ID_VP8:
>  frames->initial_pool_size += 3;
>  break;
> +case AV_CODEC_ID_H266:
> +// Add additional 16 for maximum 16 frames delay in vvc
> native decode.
> +frames->initial_pool_size += 32;
>
One frame of 8k YUV444, 10 bits, is about 200MB. Thirty-two frames amount
to approximately 6GB.Can we dynamically allocate the buffer pool?

The software decoder requires a delay of 16 frames to ensure full
utilization of CPUs. In the future, we may consider increasing this to 32
or even 64 frames.
However, for hardware decoding, given that all processing occurs on the
GPU, we do not require any delay.

+break;
>  default:
>  frames->initial_pool_size += 2;
>  }
> diff --git a/libavcodec/vaapi_vvc.c b/libavcodec/vaapi_vvc.c
> new file mode 100644
> index 00..6141005688
> --- /dev/null
> +++ b/libavcodec/vaapi_vvc.c
> @@ -0,0 +1,657 @@
> +/*
> + * VVC HW decode acceleration through VA API
> + *
> + * Copyright (c) 2024 Intel Corporation
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the 

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/hevc_ps: --typo

2024-04-02 Thread James Almer

On 4/1/2024 5:56 PM, Michael Niedermayer wrote:

Fixes: null pointer dereference
Fixes: 
67737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4858162608930816

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 38b3721a6d5..25f087ed754 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -460,7 +460,7 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb, 
AVCodecContext *avctx,
  int ret = AVERROR_INVALIDDATA;
  HEVCVPS *vps;
  
-if (ps->pps_list[vps_id]) {

+if (ps->vps_list[vps_id]) {
  const HEVCVPS *vps1 = ps->vps_list[vps_id];
  if (vps1->data_size == nal_size &&
  !memcmp(vps1->data, gb->buffer, vps1->data_size))


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 2/6] avformat/mov: Check that tile_item_list is initialized in read_image_iovl()

2024-04-02 Thread James Almer

On 4/1/2024 8:49 PM, Michael Niedermayer wrote:

On Mon, Apr 01, 2024 at 06:54:35PM -0300, James Almer wrote:

On 4/1/2024 5:56 PM, Michael Niedermayer wrote:

Fixes: null pointer dereference
Fixes: 
67494/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6528714521247744

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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 7bdeeb99f98..fa4c237c0d8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9364,6 +9364,10 @@ static int read_image_iovl(AVFormatContext *s, const 
HEIFGrid *grid,
   }
   for (int i = 0; i < tile_grid->nb_tiles; i++) {
+if (!grid->tile_item_list[i]) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}


This should not happen. We shouldn't get this far if the array was not
filled.

Can you please test the following?


diff --git a/libavformat/mov.c b/libavformat/mov.c
index 7bdeeb99f9..fb0113b149 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -9397,8 +9397,9 @@ static int mov_parse_tiles(AVFormatContext *s)

  for (int j = 0; j < grid->nb_tiles; j++) {
  int tile_id = grid->tile_id_list[j];
+int k;

-for (int k = 0; k < mov->nb_heif_item; k++) {
+for (k = 0; k < mov->nb_heif_item; k++) {
  HEIFItem *item = >heif_item[k];
  AVStream *st = item->st;

@@ -9424,6 +9425,13 @@ static int mov_parse_tiles(AVFormatContext *s)
  break;
  }

+if (k == grid->nb_tiles) {
+av_log(s, AV_LOG_WARNING, "HEIF item id %d referenced by grid id %d 
doesn't "
+  "exist\n",
+   tile_id, grid->item->item_id);
+ff_remove_stream_group(s, stg);
+loop = 0;
+}
  if (!loop)
  break;
  }


i confirm the code fixes the issue, please apply (if it passes fate) and 
backport (if needed)


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

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


Re: [FFmpeg-devel] [PATCH 3/3] avformat/mov: fix the entry count overflow check in the keys atom

2024-04-02 Thread James Almer

On 4/2/2024 12:30 AM, Andreas Rheinhardt wrote:

James Almer:

Signed-off-by: James Almer 
---
  libavformat/mov.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index a935ef7326..9fca402896 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5025,7 +5025,7 @@ static int mov_read_keys(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
  avio_skip(pb, 4);
  count = avio_rb32(pb);
  atom.size -= 8;
-if (count > UINT_MAX / sizeof(*c->meta_keys) - 1) {
+if (count + 1LL > UINT_MAX / sizeof(*c->meta_keys)) {
  av_log(c->fc, AV_LOG_ERROR,
 "The 'keys' atom with the invalid key count: %"PRIu32"\n", 
count);
  return AVERROR_INVALIDDATA;


What is supposed to be wrong here in the first place? The only thing I
can think of is the case in which sizeof(*c->meta_keys) is > UINT_MAX,
in which case the rhs would wrap around. But I don't think that is what
you meant given that sizeof(*c->meta_keys) == sizeof(char*).
Anyway, a simpler check that works even if sizeof(*c->meta_keys) were
insanely large is "count >= UINT_MAX / sizeof(*c->meta_keys)".


I misread the check, so there's nothing wrong with it. But I'll apply 
that suggestion of yours in any case since it's simpler than the current 
one.

___
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] 7.0 Name

2024-04-02 Thread myp...@gmail.com
On Tue, Apr 2, 2024 at 4:01 AM Michael Niedermayer
 wrote:
>
> Hi all
>
> I think we didnt decide on a name for 7.0 yet
>
> Previously suggested names:
> Darwin,
> De broglie,
> Dijkstra,
> Galois,
> Gauss,
> Jacobi,
> Jemison
> Johnson
> Leavitt
> Maxwell,
> Mellin,
> Perelman,
> Poincaré,
> Ramanujan,
> Sagan,
> Ting
> Viterbi,
> Voltaire,
> de Sitter,
>
> Please reply with what you prefer or add more to the list.
> If we end in a tie, previously suggested names will be favoured
> I will vote last so that i can resolve a tie if one occurs.
>
> thx
>
Viterbi
___
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 5/7] avcodec/dsddec: Fix decoding LSBF samples

2024-04-02 Thread Andreas Rheinhardt
Peter Ross:
> On Tue, Apr 02, 2024 at 03:37:06AM +0200, Andreas Rheinhardt wrote:
>> ff_dsd2pcm_translate() works internally by converting LSBF input
>> to MSBF upon reading; its buffer is therefore always MSBF
>> and should therefore be initialized with MSBF silence;
>> but this is not true since e3d8963c3cb5b8cd31460dd9b3b9dba2a2343bf5
>> which this patch effectively reverts.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavcodec/dsddec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
>> index 22009c70ef..2bb2e73b75 100644
>> --- a/libavcodec/dsddec.c
>> +++ b/libavcodec/dsddec.c
>> @@ -56,7 +56,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>>  if (!s)
>>  return AVERROR(ENOMEM);
>>  
>> -silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == 
>> AV_CODEC_ID_DSD_LSBF_PLANAR ? DSD_SILENCE_REVERSED : DSD_SILENCE;
>> +silence = DSD_SILENCE;
>>  for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
>>  s[i].pos = 0;
>>  memset(s[i].buf, silence, sizeof(s[i].buf));
>> -- 
> 
> ok.
> 
> with this patch, DSD_SILENCE, DSD_SILENCE_REVERSED macros and even the silence
> var are no longer neccessary.
> 
> i suggest reverting the memset line and attached comment back to way it was in
> the initial commit (5f4f9ee99f4e9ab980bb18475009c701ba47a74f).
> 

I see you haven't made it till the next commit yet.

- 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] 7.0 Name

2024-04-02 Thread Ingo Oppermann

> On 1 Apr 2024, at 22:00, Michael Niedermayer  wrote:
> 
> Hi all
> 
> I think we didnt decide on a name for 7.0 yet
> 
> Previously suggested names:
> Darwin,
> De broglie,
> Dijkstra,
> Galois,
> Gauss,
> Jacobi,
> Jemison
> Johnson
> Leavitt
> Maxwell,
> Mellin,
> Perelman,
> Poincaré,
> Ramanujan,
> Sagan,
> Ting
> Viterbi,
> Voltaire,
> de Sitter,


Leavitt

> 
> Please reply with what you prefer or add more to the list.
> If we end in a tie, previously suggested names will be favoured
> I will vote last so that i can resolve a tie if one occurs.
> 
> thx
> 
> -- 
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> No snowflake in an avalanche ever feels responsible. -- Voltaire
> ___
> 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 2/2] libavfilter/dnn_io_proc: Take step into consideration when crop frame

2024-04-02 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_io_proc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c
index e5d6edb301..d2ec9f63f5 100644
--- a/libavfilter/dnn/dnn_io_proc.c
+++ b/libavfilter/dnn/dnn_io_proc.c
@@ -350,6 +350,7 @@ int ff_frame_to_dnn_classify(AVFrame *frame, DNNData 
*input, uint32_t bbox_index
 const AVDetectionBBoxHeader *header;
 const AVDetectionBBox *bbox;
 AVFrameSideData *sd = av_frame_get_side_data(frame, 
AV_FRAME_DATA_DETECTION_BBOXES);
+int max_step[4] = { 0 };
 av_assert0(sd);
 
 /* (scale != 1 and scale != 0) or mean != 0 */
@@ -405,8 +406,9 @@ int ff_frame_to_dnn_classify(AVFrame *frame, DNNData 
*input, uint32_t bbox_index
 offsety[1] = offsety[2] = AV_CEIL_RSHIFT(top, desc->log2_chroma_h);
 offsety[0] = offsety[3] = top;
 
+av_image_fill_max_pixsteps(max_step, NULL, desc);
 for (int k = 0; frame->data[k]; k++)
-bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k] + 
offsetx[k];
+bbox_data[k] = frame->data[k] + offsety[k] * frame->linesize[k] + 
offsetx[k] * max_step[k];
 
 sws_scale(sws_ctx, (const uint8_t *const *)_data, frame->linesize,
0, height,
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/2] libavfilter/dnn_backend_openvino: Check bbox's height

2024-04-02 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Check bbox's height with frame's height rather than frame's width.

Signed-off-by: Wenbin Chen 
---
 libavfilter/dnn/dnn_backend_openvino.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/dnn/dnn_backend_openvino.c 
b/libavfilter/dnn/dnn_backend_openvino.c
index 1e2c2404c7..8907bef69b 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -1200,7 +1200,7 @@ static int contain_valid_detection_bbox(AVFrame *frame)
 if (bbox->x < 0 || bbox->w < 0 || bbox->x + bbox->w >= frame->width) {
 return 0;
 }
-if (bbox->y < 0 || bbox->h < 0 || bbox->y + bbox->h >= frame->width) {
+if (bbox->y < 0 || bbox->h < 0 || bbox->y + bbox->h >= frame->height) {
 return 0;
 }
 
-- 
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] Request: Memory cache to avoid write lags to storage.

2024-04-02 Thread texrayk-sup--- via ffmpeg-devel
This feature caches data in memory that is scheduled to be written to storage.

When data writing cannot keep up due to storage lag or other reasons,
The data is cached in ffmpeg memory space up to the memory capacity specified 
by this option.
Memory Size (M,G, or Specify % of Available capacity)
eg. If the available capacity is 10GB and specify 80%, up to 8GB will be used.

___
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 5/7] avcodec/dsddec: Fix decoding LSBF samples

2024-04-02 Thread Peter Ross
On Tue, Apr 02, 2024 at 03:37:06AM +0200, Andreas Rheinhardt wrote:
> ff_dsd2pcm_translate() works internally by converting LSBF input
> to MSBF upon reading; its buffer is therefore always MSBF
> and should therefore be initialized with MSBF silence;
> but this is not true since e3d8963c3cb5b8cd31460dd9b3b9dba2a2343bf5
> which this patch effectively reverts.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/dsddec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/dsddec.c b/libavcodec/dsddec.c
> index 22009c70ef..2bb2e73b75 100644
> --- a/libavcodec/dsddec.c
> +++ b/libavcodec/dsddec.c
> @@ -56,7 +56,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>  if (!s)
>  return AVERROR(ENOMEM);
>  
> -silence = avctx->codec_id == AV_CODEC_ID_DSD_LSBF || avctx->codec_id == 
> AV_CODEC_ID_DSD_LSBF_PLANAR ? DSD_SILENCE_REVERSED : DSD_SILENCE;
> +silence = DSD_SILENCE;
>  for (i = 0; i < avctx->ch_layout.nb_channels; i++) {
>  s[i].pos = 0;
>  memset(s[i].buf, silence, sizeof(s[i].buf));
> -- 

ok.

with this patch, DSD_SILENCE, DSD_SILENCE_REVERSED macros and even the silence
var are no longer neccessary.

i suggest reverting the memset line and attached comment back to way it was in
the initial commit (5f4f9ee99f4e9ab980bb18475009c701ba47a74f).

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


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

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


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_hevc: Add support for Main Intra & Main 10 Intra

2024-04-02 Thread Xiang, Haihao
On Ma, 2024-04-01 at 21:11 +0100, Mark Thompson wrote:
> On 28/03/2024 02:07, Xiang, Haihao wrote:
> > From: Haihao Xiang 
> > 
> > Both Main Intra and Main 10 Intra are Rext, we may use Main and Main 10
> > instead for decoding. This patch fixes the error below:
> > 
> > [hevc @ 0x55a771b80a00] No support for codec hevc profile 4.
> > [hevc @ 0x55a771b80a00] Failed setup for format vaapi: hwaccel
> > initialisation returned error.
> > 
> > Signed-off-by: Haihao Xiang 
> > ---
> >   libavcodec/vaapi_hevc.c | 7 +++
> >   1 file changed, 7 insertions(+)
> > 
> > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> > index 3bdd2dd1b8..83b94d1a55 100644
> > --- a/libavcodec/vaapi_hevc.c
> > +++ b/libavcodec/vaapi_hevc.c
> > @@ -612,6 +612,13 @@ VAProfile
> > ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
> >   av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n",
> > profile->name);
> >   }
> >   
> > +#if VA_CHECK_VERSION(0, 37, 0)
> > +    if (!strcmp(profile->name, "Main Intra"))
> > +    return VAProfileHEVCMain;
> > +    else if (!strcmp(profile->name, "Main 10 Intra"))
> > +    return VAProfileHEVCMain10;
> > +#endif
> > +
> >   #if VA_CHECK_VERSION(1, 2, 0)
> >   if (!strcmp(profile->name, "Main 12") ||
> >   !strcmp(profile->name, "Main 12 Intra"))
> 
> What if high_precision_offsets_enabled_flag is set?
> 
> (That doesn't matter for the VAAPI encoder setting the profile because we
> always have it as zero.)

Here use VAProfileHEVCMain or VAProfileHEVCMain10 to create VAConfig for
decoding,  avctx->profile (4) is not changed.
high_precision_offsets_enabled_flag is set in VAPictureParameterBufferHEVCRext
when avctx->profile is 4.

BRs
Haihao

> 
> Thanks,
> 
> - Mark
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
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 v1 6/7] lavc/vvc_dec: Add hardware decode API

2024-04-02 Thread Wang, Fei W
On Thu, 2024-03-28 at 03:04 +0100, Andreas Rheinhardt wrote:
> fei.w.wang-at-intel@ffmpeg.org:
> > From: Fei Wang 
> > 
> > Signed-off-by: Fei Wang 
> > ---
> >  libavcodec/vvc/vvc_refs.c |  6 
> >  libavcodec/vvc/vvcdec.c   | 67
> > +++
> >  libavcodec/vvc/vvcdec.h   |  5 +++
> >  3 files changed, 72 insertions(+), 6 deletions(-)
> > 
> > diff --git a/libavcodec/vvc/vvc_refs.c b/libavcodec/vvc/vvc_refs.c
> > index bf70777550..c9f89a5a0a 100644
> > --- a/libavcodec/vvc/vvc_refs.c
> > +++ b/libavcodec/vvc/vvc_refs.c
> > @@ -25,6 +25,7 @@
> >  #include "libavutil/thread.h"
> >  #include "libavcodec/refstruct.h"
> >  #include "libavcodec/thread.h"
> > +#include "libavcodec/decode.h"
> >  
> >  #include "vvc_refs.h"
> >  
> > @@ -56,6 +57,7 @@ void ff_vvc_unref_frame(VVCFrameContext *fc,
> > VVCFrame *frame, int flags)
> >  ff_refstruct_unref(>rpl_tab);
> >  
> >  frame->collocated_ref = NULL;
> > +ff_refstruct_unref(>hwaccel_picture_private);
> >  }
> >  }
> >  
> > @@ -138,6 +140,10 @@ static VVCFrame *alloc_frame(VVCContext *s,
> > VVCFrameContext *fc)
> >  if (!frame->progress)
> >  goto fail;
> >  
> > +ret = ff_hwaccel_frame_priv_alloc(s->avctx, 
> > >hwaccel_picture_private);
> > +if (ret < 0)
> > +goto fail;
> > +
> >  return frame;
> >  fail:
> >  ff_vvc_unref_frame(fc, frame, ~0);
> > diff --git a/libavcodec/vvc/vvcdec.c b/libavcodec/vvc/vvcdec.c
> > index d5704aca25..f2e269ce76 100644
> > --- a/libavcodec/vvc/vvcdec.c
> > +++ b/libavcodec/vvc/vvcdec.c
> > @@ -24,6 +24,8 @@
> >  #include "libavcodec/decode.h"
> >  #include "libavcodec/profiles.h"
> >  #include "libavcodec/refstruct.h"
> > +#include "libavcodec/hwconfig.h"
> > +#include "libavcodec/hwaccel_internal.h"
> >  #include "libavutil/cpu.h"
> >  #include "libavutil/thread.h"
> >  
> > @@ -563,6 +565,8 @@ static int ref_frame(VVCFrame *dst, const
> > VVCFrame *src)
> >  
> >  ff_refstruct_replace(>rpl_tab, src->rpl_tab);
> >  ff_refstruct_replace(>rpl, src->rpl);
> > +ff_refstruct_replace(>hwaccel_picture_private,
> > +  src->hwaccel_picture_private);
> >  dst->nb_rpl_elems = src->nb_rpl_elems;
> >  
> >  dst->poc = src->poc;
> > @@ -718,17 +722,41 @@ static int slice_start(SliceContext *sc,
> > VVCContext *s, VVCFrameContext *fc,
> >  return 0;
> >  }
> >  
> > +static enum AVPixelFormat get_format(AVCodecContext *avctx, const
> > VVCSPS *sps)
> > +{
> > +#define HWACCEL_MAX 0
> > +
> > +enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts;
> > +
> > +switch (sps->pix_fmt) {
> > +case AV_PIX_FMT_YUV420P:
> > +break;
> > +case AV_PIX_FMT_YUV420P10:
> > +break;
> > +}
> > +
> > +*fmt++ = sps->pix_fmt;
> > +*fmt = AV_PIX_FMT_NONE;
> > +
> > +return ff_get_format(avctx, pix_fmts);
> > +}
> > +
> >  static void export_frame_params(VVCContext *s, const
> > VVCFrameContext *fc)
> >  {
> >  AVCodecContext *c = s->avctx;
> >  const VVCSPS *sps = fc->ps.sps;
> >  const VVCPPS *pps = fc->ps.pps;
> >  
> > -c->pix_fmt  = sps->pix_fmt;
> > -c->coded_width  = pps->width;
> > -c->coded_height = pps->height;
> > -c->width= pps->width  - ((pps->r-
> > >pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) <<
> > sps->hshift[CHROMA]);
> > -c->height   = pps->height - ((pps->r-
> > >pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) <<
> > sps->vshift[CHROMA]);
> > +// Reset HW config if pix_fmt/w/h change.
> > +if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width 
> > || c->coded_height != pps->height) {
> > +c->coded_width  = pps->width;
> > +c->coded_height = pps->height;
> > +c->pix_fmt  = get_format(c, sps);
> > +s->pix_fmt  = sps->pix_fmt;
> > +}
> > +
> > +c->width  = pps->width  - ((pps->r->pps_conf_win_left_offset +
> > pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]);
> > +c->height = pps->height - ((pps->r->pps_conf_win_top_offset +
> > pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]);
> >  }
> >  
> >  static int frame_setup(VVCFrameContext *fc, VVCContext *s)
> > @@ -771,6 +799,20 @@ static int decode_slice(VVCContext *s,
> > VVCFrameContext *fc, const H2645NAL *nal,
> >  ret = slice_init_entry_points(sc, fc, nal, unit);
> >  if (ret < 0)
> >  return ret;
> > +
> > +if (s->avctx->hwaccel) {
> > +if (is_first_slice) {
> > +ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0);
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> > +ret = FF_HW_CALL(s->avctx, decode_slice,
> > + nal->raw_data, nal->raw_size);
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> >  fc->nb_slices++;
> >  
> >  return 0;
> > @@ -885,9 +927,20 @@ 

Re: [FFmpeg-devel] [PATCH v1 1/7] lavc/vaapi_dec: Create VA parameters dynamically

2024-04-02 Thread Wang, Fei W
On Mon, 2024-04-01 at 20:52 +0100, Mark Thompson wrote:
> On 28/03/2024 01:26, fei.w.wang-at-intel@ffmpeg.org wrote:
> > From: Fei Wang 
> > 
> > Signed-off-by: Fei Wang 
> > ---
> >   libavcodec/vaapi_decode.c | 29 ++---
> >   libavcodec/vaapi_decode.h |  7 ++-
> >   2 files changed, 24 insertions(+), 12 deletions(-)
> 
> This is because the VVC code is going to want to make a lot more of
> these param buffers - can we just set a slightly larger fixed limit?
> 
> If you always need 20 buffers (say), then this has turned 1
> allocation per picture into 3 and used more memory in the non-VVC
> case as well because of the overhead of that (but if you might
> variably need up to 200 then this is completely fair).

VVC support 1000 slices and 990 tile columns, and other buffer like
APS/tile_rows... So there will be 1990+ buffers needed at most in
theory.

For other non-VVC case, 16 buffers will be created which is same with
before.

> 
> > diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> > index cca94b5336..1b1972a2a9 100644
> > --- a/libavcodec/vaapi_decode.c
> > +++ b/libavcodec/vaapi_decode.c
> > @@ -38,12 +38,23 @@ int
> > ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
> >   {
> >   VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data;
> >   VAStatus vas;
> > -VABufferID buffer;
> >   
> > -av_assert0(pic->nb_param_buffers + 1 <= MAX_PARAM_BUFFERS);
> > +av_assert0(pic->nb_param_buffers <= pic->param_allocated);
> > +if (pic->nb_param_buffers == pic->param_allocated) {
> > +pic->param_buffers =
> > +av_realloc_array(pic->param_buffers,
> > + pic->param_allocated + 16,
> > + sizeof(*pic->param_buffers));
> 
> Use av_reallocp_array() to avoid leaking the pointer on failure.
> 
> > +if (!pic->param_buffers)
> > +return AVERROR(ENOMEM);
> > +
> > +pic->param_allocated += 16;
> > +}
> > +av_assert0(pic->nb_param_buffers + 1 <= pic->param_allocated);
> >   
> >   vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
> > - type, size, 1, (void*)data, );
> > + type, size, 1, (void*)data,
> > + >param_buffers[pic-
> > >nb_param_buffers]);
> >   if (vas != VA_STATUS_SUCCESS) {
> >   av_log(avctx, AV_LOG_ERROR, "Failed to create parameter "
> >  "buffer (type %d): %d (%s).\n",
> > @@ -51,14 +62,14 @@ int
> > ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
> >   return AVERROR(EIO);
> >   }
> >   
> > -pic->param_buffers[pic->nb_param_buffers++] = buffer;
> > -
> >   av_log(avctx, AV_LOG_DEBUG, "Param buffer (type %d, %zu
> > bytes) "
> > -   "is %#x.\n", type, size, buffer);
> > +   "is %#x.\n", type, size, pic->param_buffers[pic-
> > >nb_param_buffers]);
> > +
> > +++pic->nb_param_buffers;
> > +
> >   return 0;
> >   }
> >   
> > -
> >   int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
> > VAAPIDecodePicture *pic,
> > const void *params_data,
> > @@ -215,6 +226,8 @@ fail:
> >   fail_at_end:
> >   exit:
> >   pic->nb_param_buffers = 0;
> > +pic->param_allocated  = 0;
> > +av_freep(>param_buffers);
> >   pic->nb_slices= 0;
> >   pic->slices_allocated = 0;
> >   av_freep(>slice_buffers);
> > @@ -228,6 +241,8 @@ int ff_vaapi_decode_cancel(AVCodecContext
> > *avctx,
> >   ff_vaapi_decode_destroy_buffers(avctx, pic);
> >   
> >   pic->nb_param_buffers = 0;
> > +pic->param_allocated  = 0;
> > +av_freep(>param_buffers);
> >   pic->nb_slices= 0;
> >   pic->slices_allocated = 0;
> >   av_freep(>slice_buffers);
> > diff --git a/libavcodec/vaapi_decode.h b/libavcodec/vaapi_decode.h
> > index 6beda14e52..a41d7ff2ff 100644
> > --- a/libavcodec/vaapi_decode.h
> > +++ b/libavcodec/vaapi_decode.h
> > @@ -32,15 +32,12 @@ static inline VASurfaceID
> > ff_vaapi_get_surface_id(AVFrame *pic)
> >   return (uintptr_t)pic->data[3];
> >   }
> >   
> > -enum {
> > -MAX_PARAM_BUFFERS = 16,
> > -};
> > -
> >   typedef struct VAAPIDecodePicture {
> >   VASurfaceID   output_surface;
> >   
> >   intnb_param_buffers;
> > -VABufferIDparam_buffers[MAX_PARAM_BUFFERS];
> > +VABufferID   *param_buffers;
> 
> Previously the array was zeroed at allocation but now it isn't.  Can
> you confirm that that isn't a problem?

It is should not be a problem, all buffers visited and destroyed
through nb_param_buffers which record if the buffer is valid.

Thanks
Fei

> 
> > +int   param_allocated;
> 
> Maybe "nb_param_buffers_allocated" would be clearer.
> 
> >   
> >   intnb_slices;
> >   VABufferID   *slice_buffers;
> 
>