[FFmpeg-devel] [PATCH 7/8] aactab: add new scalefactor offset tables for 96/768pt windows
--- libavcodec/aactab.c | 117 libavcodec/aactab.h | 4 ++ 2 files changed, 121 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index dfb2dfd98d..18afa69bad 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -154,6 +154,10 @@ const uint8_t ff_aac_num_swb_960[] = { 40, 40, 46, 49, 49, 49, 46, 46, 42, 42, 42, 40, 40 }; +const uint8_t ff_aac_num_swb_768[] = { +37, 37, 41, 43, 43, 43, 43, 43, 39, 39, 39, 37, 37 +}; + const uint8_t ff_aac_num_swb_512[] = { 0, 0, 0, 36, 36, 37, 31, 31, 0, 0, 0, 0, 0 }; @@ -170,6 +174,10 @@ const uint8_t ff_aac_num_swb_120[] = { 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15 }; +const uint8_t ff_aac_num_swb_96[] = { +12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14 +}; + const uint8_t ff_aac_pred_sfb_max[] = { 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 34 }; @@ -1806,6 +1814,99 @@ static const uint16_t swb_offset_120_8[] = 0, 4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 120 }; +static const uint16_t swb_offset_768_96[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, +40, 44, 48, 52, 56, 64, 72, 80, 88, 96, +108, 120, 132, 144, 156, 172, 188, 212, 240, 276, +320, 384, 448, 512, 576, 640, 704, 768 +}; + +static const uint16_t swb_offset_768_64[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, +44, 48, 52, 56, 64, 72, 80, 88, 100, 112, 124, +140, 156, 172, 192, 216, 240, 268, 304, 344, 384, 424, +464, 504, 544, 584, 624, 664, 704, 744, 768 +}; + +static const uint16_t swb_offset_768_48[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, +56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, +196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, +544, 576, 608, 640, 672, 704, 736, 768 +}; + +static const uint16_t swb_offset_768_32[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 48, +56, 64, 72, 80, 88, 96, 108, 120, 132, 144, 160, 176, +196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512, +544, 576, 608, 640, 672, 704, 736, 768 +}; + +static const uint16_t swb_offset_768_24[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, +52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 136, 148, +160, 172, 188, 204, 220, 240, 260, 284, 308, 336, 364, 396, +432, 468, 508, 552, 600, 652, 704, 768 +}; + +static const uint16_t swb_offset_768_16[] = +{ +0, 8, 16, 24, 32, 40, 48, 56, 64, +72, 80, 88, 100, 112, 124, 136, 148, 160, +172, 184, 196, 212, 228, 244, 260, 280, 300, +320, 344, 368, 396, 424, 456, 492, 532, 572, +616, 664, 716, 768 +}; + +static const uint16_t swb_offset_768_8[] = +{ +0, 12, 24, 36, 48, 60, 72, 84, 96, 108, +120, 132, 144, 156, 172, 188, 204, 220, 236, 252, +268, 288, 308, 328, 348, 372, 396, 420, 448, 476, +508, 544, 580, 620, 664, 712, 764, 768 +}; + +static const uint16_t swb_offset_96_96[] = +{ +0, 4, 8, 12, 16, 20, 24, +32, 40, 48, 64, 92, 96 +}; + +static const uint16_t swb_offset_96_64[] = +{ +0, 4, 8, 12, 16, 20, 24, +32, 40, 48, 64, 92, 96 +}; + +static const uint16_t swb_offset_96_48[] = +{ +0, 4, 8, 12, 16, 20, 28, +36, 44, 56, 68, 80, 96 +}; + +static const uint16_t swb_offset_96_24[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +36, 44, 52, 64, 76, 92, 96 +}; + +static const uint16_t swb_offset_96_16[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +32, 40, 48, 60, 72, 88, 96 +}; + +static const uint16_t swb_offset_96_8[] = +{ +0, 4, 8, 12, 16, 20, 24, 28, +36, 44, 52, 60, 72, 88, 96 +}; + const uint16_t * const ff_swb_offset_1024[] = { swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64, swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32, @@ -1822,6 +1923,14 @@ const uint16_t * const ff_swb_offset_960[] = { swb_offset_960_8 }; +const uint16_t * const ff_swb_offset_768[] = { +swb_offset_768_96, swb_offset_768_96, swb_offset_768_64, +swb_offset_768_48, swb_offset_768_48, swb_offset_768_32, +swb_offset_768_24, swb_offset_768_24, swb_offset_768_16, +swb_offset_768_16, swb_offset_768_16, swb_offset_768_8, +swb_offset_768_8 +}; + const uint16_t * const ff_swb_offset_512[] = { NULL, NULL, NULL, swb_offset_512_48, swb_offset_512_48, swb_offset_512_32, @@ -1856,6 +1965,14 @@ const uint16_t * const ff_swb_offset_120[] = { swb_offset_120_8 }; +const uint16_t * const ff_swb_offset_96[] = { +swb_offset_96_96, swb_offset_96_96, swb_offset_96_96, +swb_offset_96_48, swb_offset_96_48, swb_offset_96_48, +swb_offset_96_24, swb_offset_96_24, swb_offset_96_16, +swb_offset_96_16, swb_offset_96_16, swb_offset_96_8, +swb_offset_96_8 +}; + // @} /* @name ff_tns_max_bands diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
[FFmpeg-devel] [PATCH 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
This commit adds a decoder for the frequency-domain part of USAC. What works: - Mono - Stereo (no prediction) - Stereo (mid/side coding) What doesn't: - Preroll decoding (every single decoder seems faulty or weird?) - Complex stereo prediction Known issues: - Spec incompliance (noise synthesis in particular) - Lack of robustness --- libavcodec/aac/Makefile |2 +- libavcodec/aac/aacdec.c | 181 ++-- libavcodec/aac/aacdec.h | 179 libavcodec/aac/aacdec_ac.c | 224 + libavcodec/aac/aacdec_ac.h | 54 ++ libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 192 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1230 ++ libavcodec/aac/aacdec_usac.h | 47 + libavcodec/aactab.c |5 + libavcodec/aactab.h |3 + 13 files changed, 2093 insertions(+), 75 deletions(-) create mode 100644 libavcodec/aac/aacdec_ac.c create mode 100644 libavcodec/aac/aacdec_ac.h create mode 100644 libavcodec/aac/aacdec_lpd.c create mode 100644 libavcodec/aac/aacdec_lpd.h create mode 100644 libavcodec/aac/aacdec_usac.c create mode 100644 libavcodec/aac/aacdec_usac.h diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile index 8b0bfff3e5..70b1dca274 100644 --- a/libavcodec/aac/Makefile +++ b/libavcodec/aac/Makefile @@ -3,6 +3,6 @@ clean:: OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \ aac/aacdec_float.o aac/aacdec_usac.o \ -aac/aacdec_ac.o +aac/aacdec_ac.o aac/aacdec_lpd.o OBJS-$(CONFIG_AAC_FIXED_DECODER)+= aac/aacdec.o aac/aacdec_tab.o \ aac/aacdec_fixed.o diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 6f37ac5361..5dcbe46fb9 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -40,6 +40,7 @@ #include "aacdec.h" #include "aacdec_tab.h" +#include "aacdec_usac.h" #include "libavcodec/aac.h" #include "libavcodec/aac_defines.h" @@ -535,6 +536,8 @@ static av_cold void flush(AVCodecContext *avctx) } } } + +ff_aac_usac_reset_state(ac, &ac->oc[1]); } /** @@ -993,13 +996,14 @@ static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, */ static int decode_audio_specific_config_gb(AACDecContext *ac, AVCodecContext *avctx, - MPEG4AudioConfig *m4ac, + OutputConfiguration *oc, GetBitContext *gb, int get_bit_alignment, int sync_extension) { int i, ret; GetBitContext gbc = *gb; +MPEG4AudioConfig *m4ac = &oc->m4ac; MPEG4AudioConfig m4ac_bak = *m4ac; if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension, avctx)) < 0) { @@ -1033,14 +1037,22 @@ static int decode_audio_specific_config_gb(AACDecContext *ac, case AOT_ER_AAC_LC: case AOT_ER_AAC_LD: if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment, -m4ac, m4ac->chan_config)) < 0) + &oc->m4ac, m4ac->chan_config)) < 0) return ret; break; case AOT_ER_AAC_ELD: if ((ret = decode_eld_specific_config(ac, avctx, gb, - m4ac, m4ac->chan_config)) < 0) + &oc->m4ac, m4ac->chan_config)) < 0) +return ret; +break; +#if CONFIG_AAC_DECODER +case AOT_USAC_NOSBR: /* fallthrough */ +case AOT_USAC: +if ((ret = ff_aac_usac_config_decode(ac, avctx, gb, + oc, m4ac->chan_config)) < 0) return ret; break; +#endif default: avpriv_report_missing_feature(avctx, "Audio object type %s%d", @@ -1060,7 +1072,7 @@ static int decode_audio_specific_config_gb(AACDecContext *ac, static int decode_audio_specific_config(AACDecContext *ac, AVCodecContext *avctx, -MPEG4AudioConfig *m4ac, +OutputConfiguration *oc, const uint8_t *data, int64_t bit_size, int sync_extension) { @@ -1080,7 +1092,7 @@ static int decode_audio_specific_config(AACDecContext *ac, if ((ret = init_get_bits(&gb, data, bit_size)) < 0) return ret; -return decode_audio_specific_c
Re: [FFmpeg-devel] [PATCH] libsvtav1: Enable 2-pass encoding
Fredrik Lundkvist via ffmpeg-devel: >>> + ret = av_reallocp(¶m->rc_stats_buffer.buf, param->rc_stats_buffer.sz); > >> Why realloc instead of malloc? > > As far as I gathered, rc_stats_buffer.buf is already allocated by SVT-AV1; if > malloc is preferred, I can change it and test to make sure it doesn’t cause > any obvious issues. > https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/Source/API/EbSvtAv1Enc.h?ref_type=heads#L163 says that this pointer is a non-ownership pointer. Which would imply that you can't realloc the initial pointer at all and have to simply replace it with something of our own. (That we would probably also need to free on our own.) > >> Wouldn't it be safer to free rc_stats_buffer.buf and set rc_stats_buffer.sz >> to 0 on failure here too? > > Absolutely agree on setting rc_stats_buffer.sz to 0, not quite sure about > freeing rc_stats_buffer_buf it is allocated by SVT-AV1. > > Thank you for the review, the other comments will be fixed in V2. > > /Fredrik > ___ > 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 v4 3/5] avformat/network: add ff_neterror2() for cases where we already have an error
Le 16 mai 2024 12:33:36 GMT+03:00, Andrew Sayers a écrit : >For example, WSAStartup()'s documentation says: > >"A call to the WSAGetLastError function is not needed and should not be > used" >--- > libavformat/network.c | 5 - > libavformat/network.h | 12 > 2 files changed, 16 insertions(+), 1 deletion(-) > >diff --git a/libavformat/network.c b/libavformat/network.c >index 5d0d05c5f1..351dc34bb6 100644 >--- a/libavformat/network.c >+++ b/libavformat/network.c >@@ -123,7 +123,10 @@ void ff_network_close(void) > #if HAVE_WINSOCK2_H > int ff_neterror(void) > { >-int err = WSAGetLastError(); >+return ff_neterror2(WSAGetLastError()); >+} >+int ff_neterror2(int err) Err, please. Keep this to the Windows back-end. Nothing good is going to happen with a function that does nothing (on other platforms) and has a nondescript numbered name. >+{ > switch (err) { > case WSAEWOULDBLOCK: > return AVERROR(EAGAIN); >diff --git a/libavformat/network.h b/libavformat/network.h >index f338694212..7c8f81a050 100644 >--- a/libavformat/network.h >+++ b/libavformat/network.h >@@ -63,6 +63,12 @@ > * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) > */ > int ff_neterror(void); >+/* >+ * @brief ff_neterror()-style AVERROR >+ * @param err error code (usually an errno or Windows Sockets Error Code) >+ * @note Windows Sockets Error Codes are only supported in Windows >+ */ >+int ff_neterror2(int err); > #else > #include > #include >@@ -76,6 +82,12 @@ int ff_neterror(void); > * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) > */ > #define ff_neterror() AVERROR(errno) >+/* >+ * @brief ff_neterror()-style AVERROR >+ * @param err error code (usually an errno or Windows Sockets Error Code) >+ * @note Windows Sockets Error Codes are only supported in Windows >+ */ >+#define ff_neterror2(ERRNO) AVERROR(ERRNO) > #endif /* HAVE_WINSOCK2_H */ > > #if HAVE_ARPA_INET_H ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
Lynne via ffmpeg-devel: > This commit adds a decoder for the frequency-domain part of USAC. > > What works: > - Mono > - Stereo (no prediction) > - Stereo (mid/side coding) > > What doesn't: > - Preroll decoding (every single decoder seems faulty or weird?) > - Complex stereo prediction > > Known issues: > - Spec incompliance (noise synthesis in particular) > - Lack of robustness > --- > diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h > index 20545a24d4..3e6592cf0e 100644 > --- a/libavcodec/aac/aacdec.h > +++ b/libavcodec/aac/aacdec.h > @@ -42,6 +42,8 @@ > #include "libavcodec/avcodec.h" > #include "libavcodec/mpeg4audio.h" > > +#include "aacdec_ac.h" > + > typedef struct AACDecContext AACDecContext; > > /** > @@ -69,6 +71,32 @@ enum CouplingPoint { > AFTER_IMDCT = 3, > }; > > +enum AACUsacElem { > +ID_USAC_SCE = 0, > +ID_USAC_CPE = 1, > +ID_USAC_LFE = 2, > +ID_USAC_EXT = 3, > +}; > + > +enum ExtensionHeaderType { > +ID_CONFIG_EXT_FILL = 0, > +ID_CONFIG_EXT_LOUDNESS_INFO = 2, > +ID_CONFIG_EXT_STREAM_ID = 7, > +}; > + > +enum AACUsacExtension { > +ID_EXT_ELE_FILL, > +ID_EXT_ELE_MPEGS, > +ID_EXT_ELE_SAOC, > +ID_EXT_ELE_AUDIOPREROLL, > +ID_EXT_ELE_UNI_DRC, > +}; > + > +enum AACUSACLoudnessExt { > +UNIDRCLOUDEXT_TERM = 0x0, > +UNIDRCLOUDEXT_EQ = 0x1, > +}; > + > // Supposed to be equal to AAC_RENAME() in case of USE_FIXED. > #define RENAME_FIXED(name) name ## _fixed > > @@ -93,6 +121,40 @@ typedef struct LongTermPrediction { > int8_t used[MAX_LTP_LONG_SFB]; > } LongTermPrediction; > > +/* Per channel core mode */ > +typedef struct AACUsacElemData { > +uint8_t core_mode; > +uint8_t scale_factor_grouping; > + > +/* Timewarping ratio */ > +#define NUM_TW_NODES 16 > +uint8_t tw_ratio[NUM_TW_NODES]; > + > +struct { > +uint8_t acelp_core_mode : 3; > +uint8_t lpd_mode : 5; > + > +uint8_t bpf_control_info : 1; > +uint8_t core_mode_last : 1; > +uint8_t fac_data_present : 1; > + > +int last_lpd_mode; > +} ldp; > + > +struct { > +unsigned int seed; > +uint8_t level : 3; > +uint8_t offset : 5; > +} noise; > + > +struct { > +uint8_t gain; > +uint32_t kv[8 /* (1024 / 16) / 8 */][8]; > +} fac; > + > +AACArithState ac; > +} AACUsacElemData; > + > /** > * Individual Channel Stream > */ > @@ -145,6 +207,7 @@ typedef struct ChannelCoupling { > */ > typedef struct SingleChannelElement { > IndividualChannelStream ics; > +AACUsacElemData ue; ///< USAC element data > TemporalNoiseShaping tns; > enum BandType band_type[128]; ///< band types > int sfo[128]; ///< scalefactor offsets > @@ -163,25 +226,141 @@ typedef struct SingleChannelElement { > }; > } SingleChannelElement; > > +typedef struct AACUsacStereo { > +uint8_t common_window; > +uint8_t common_tw; > + > +uint8_t ms_mask_mode; > +uint8_t config_idx; > + > +struct { > +uint8_t use_prev_frame; > +uint8_t pred_dir; > +uint8_t delta_code_time; > +uint8_t pred_used[8][64]; > + > +AVComplexFloat pred[8][64]; > +} cplx; > +} AACUsacStereo; > + > /** > * channel element - generic struct for SCE/CPE/CCE/LFE > */ > typedef struct ChannelElement { > int present; > // CPE specific > +uint8_t max_sfb_ste; ///< (USAC) Maximum of both max_sfb values > uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each > scalefactor window band > // shared > SingleChannelElement ch[2]; > // CCE specific > ChannelCoupling coup; > +// USAC stereo coupling data > +AACUsacStereo us; > } ChannelElement; > > +typedef struct AACUSACLoudnessInfo { > +uint8_t drc_set_id : 6; > +uint8_t downmix_id : 7; > +struct { > +uint16_t lvl : 12; > +uint8_t present : 1; > +} sample_peak; > + > +struct { > +uint16_t lvl : 12; > +uint8_t measurement : 4; > +uint8_t reliability : 2; > +uint8_t present : 1; > +} true_peak; > + > +uint8_t nb_measurements : 4; > +struct { > +uint8_t method_def : 4; > +uint8_t method_val; > +uint8_t measurement : 4; > +uint8_t reliability : 2; > +} measurements[16]; > +} AACUSACLoudnessInfo; > + > +typedef struct AACUsacElemConfig { > +enum AACUsacElem type; > + > +uint8_t tw_mdct : 1; > +uint8_t noise_fill : 1; > + > +uint8_t stereo_config_index; > + > +struct { > +int ratio; > + > +uint8_t harmonic_sbr : 1; /* harmonicSBR */ > +uint8_t bs_intertes : 1; /* bs_interTes */ > +uint8_t bs_pvc : 1; /* bs_pvc */ > + > +struct { > +uint8_t start_freq; /* dflt_start_freq */ > +uint8_t stop_freq; /* dflt_stop_freq *
Re: [FFmpeg-devel] [PATCH v4 3/4] all: Link to "context" from all contexts with documentation
On Wed, May 15, 2024 at 06:46:19PM +0200, Lynne via ffmpeg-devel wrote: > On 15/05/2024 17:54, Andrew Sayers wrote: > > Some headings needed to be rewritten to accomodate the text, > > (hopefully) without changing the meaning. > > --- > > libavcodec/aac/aacdec.h| 2 +- > > libavcodec/aacenc.h| 2 +- > > libavcodec/ac3enc.h| 2 +- > > libavcodec/amfenc.h| 2 +- > > libavcodec/atrac.h | 2 +- > > libavcodec/avcodec.h | 3 ++- > > libavcodec/bsf.h | 2 +- > > libavcodec/cbs.h | 2 +- > > libavcodec/d3d11va.h | 3 +-- > > libavcodec/h264dsp.h | 2 +- > > libavcodec/h264pred.h | 2 +- > > libavcodec/mediacodec.h| 2 +- > > libavcodec/mpegaudiodec_template.c | 2 +- > > libavcodec/pthread_frame.c | 4 ++-- > > libavcodec/qsv.h | 6 -- > > libavcodec/sbr.h | 2 +- > > libavcodec/smacker.c | 2 +- > > libavcodec/vdpau.h | 3 ++- > > libavcodec/videotoolbox.h | 5 +++-- > > libavfilter/avfilter.h | 2 +- > > libavformat/avformat.h | 3 ++- > > libavformat/avio.h | 3 ++- > > libavutil/audio_fifo.h | 2 +- > > libavutil/hwcontext.h | 21 - > > libavutil/hwcontext_cuda.h | 2 +- > > libavutil/hwcontext_d3d11va.h | 4 ++-- > > libavutil/hwcontext_d3d12va.h | 6 +++--- > > libavutil/hwcontext_drm.h | 2 +- > > libavutil/hwcontext_dxva2.h| 4 ++-- > > libavutil/hwcontext_mediacodec.h | 2 +- > > libavutil/hwcontext_opencl.h | 4 ++-- > > libavutil/hwcontext_qsv.h | 4 ++-- > > libavutil/hwcontext_vaapi.h| 6 +++--- > > libavutil/hwcontext_vdpau.h| 2 +- > > libavutil/hwcontext_vulkan.h | 4 ++-- > > libavutil/lfg.h| 2 +- > > 36 files changed, 66 insertions(+), 57 deletions(-) > > I still don't like this part. There's no reason to link this everywhere when > no one will be bothered to. The document alone is enough IMO. Readers who don't already know the word "context" need a sign that it's a word they need to pay attention to. For example, I come from an OOP background where the word "object" is used so widely, it simply never comes up. In fact, I'm probably not the only person who followed the link to AVClass instead, which just makes FFmpeg look like a failed attempt at OOP if you don't know about contexts. Linking widely lets an attentive reader see this *before* they get the wrong end of the stick, and gives an overwhelmed newbie enough hints that this is a word they need to pay attention to. To underline the previous point - an attentive reader could probably make do with e.g. just links from AVClass and a handful of the most popular contexts. But newbies are often inefficient learners who need many reminders before they stop paying attention to random things. So linking as widely as possible makes the project more accessible to people with less experience. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 1/6] Add documentation for ff_neterrno()
--- libavformat/network.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libavformat/network.h b/libavformat/network.h index ca214087fc..728c20c9bb 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -57,6 +57,11 @@ #define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e) #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) +/* + * @brief AVERROR for the latest network function + * @return platform-specific AVERROR value + * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) + */ int ff_neterrno(void); #else #include @@ -65,6 +70,11 @@ int ff_neterrno(void); #include #include +/* + * @brief AVERROR for the latest network function + * @return platform-specific AVERROR value + * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) + */ #define ff_neterrno() AVERROR(errno) #endif /* HAVE_WINSOCK2_H */ -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 0/6] avformat/network: improve ff_neterrno()
On Thu, May 16, 2024 at 01:42:23PM +0300, Rémi Denis-Courmont wrote: > Err, please. Keep this to the Windows back-end. Nothing good is going to > happen with a function that does nothing (on other platforms) and has a > nondescript numbered name. I have no strong opinion either way, and it feels rather bikesheddable. Here's a version with the offending part moved to its own patch - I'm happy for whoever applies this to decide whether they want to keep or chuck patch 4/6 :) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 2/6] Rename "ff_neterrno()" to "ff_neterror()"
This function does not check errno on Windows, so the old name was misleading. Actual command: sed -i -e 's/ff_neterrno/ff_neterror/g' $( git grep -l ff_neterrno ) --- libavformat/network.c | 24 libavformat/network.h | 4 ++-- libavformat/rtpproto.c | 8 libavformat/sctp.c | 10 +- libavformat/tcp.c | 8 libavformat/udp.c | 32 libavformat/unix.c | 6 +++--- libavformat/url.h | 2 +- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libavformat/network.c b/libavformat/network.c index f752efc411..5d0d05c5f1 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -72,7 +72,7 @@ int ff_network_wait_fd(int fd, int write) struct pollfd p = { .fd = fd, .events = ev, .revents = 0 }; int ret; ret = poll(&p, 1, POLLING_TIME); -return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN); +return ret < 0 ? ff_neterror() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN); } int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb) @@ -121,7 +121,7 @@ void ff_network_close(void) } #if HAVE_WINSOCK2_H -int ff_neterrno(void) +int ff_neterror(void) { int err = WSAGetLastError(); switch (err) { @@ -168,7 +168,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout, ret = poll(p, nfds, POLLING_TIME); if (ret != 0) { if (ret < 0) -ret = ff_neterrno(); +ret = ff_neterror(); if (ret == AVERROR(EINTR)) continue; break; @@ -217,11 +217,11 @@ int ff_listen(int fd, const struct sockaddr *addr, } ret = bind(fd, addr, addrlen); if (ret) -return ff_neterrno(); +return ff_neterror(); ret = listen(fd, 1); if (ret) -return ff_neterrno(); +return ff_neterror(); return ret; } @@ -236,7 +236,7 @@ int ff_accept(int fd, int timeout, URLContext *h) ret = accept(fd, NULL, NULL); if (ret < 0) -return ff_neterrno(); +return ff_neterror(); if (ff_socket_nonblock(ret, 1) < 0) av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); @@ -267,7 +267,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr, av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); while ((ret = connect(fd, addr, addrlen))) { -ret = ff_neterrno(); +ret = ff_neterror(); switch (ret) { case AVERROR(EINTR): if (ff_check_interrupt(&h->interrupt_callback)) @@ -280,7 +280,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr, return ret; optlen = sizeof(ret); if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) -ret = AVUNERROR(ff_neterrno()); +ret = AVUNERROR(ff_neterror()); if (ret != 0) { char errbuf[100]; ret = AVERROR(ret); @@ -365,7 +365,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, h); if (attempt->fd < 0) -return ff_neterrno(); +return ff_neterror(); attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000; attempt->addr = ai; @@ -381,7 +381,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, } while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) { -ret = ff_neterrno(); +ret = ff_neterror(); switch (ret) { case AVERROR(EINTR): if (ff_check_interrupt(&h->interrupt_callback)) { @@ -478,7 +478,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, // a successful connection or an error). optlen = sizeof(last_err); if (getsockopt(attempts[i].fd, SOL_SOCKET, SO_ERROR, &last_err, &optlen)) -last_err = ff_neterrno(); +last_err = ff_neterror(); else if (last_err != 0) last_err = AVERROR(last_err); if (last_err == 0) { @@ -587,6 +587,6 @@ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname) void ff_log_net_error(void *ctx, int level, const char* prefix) { char errbuf[100]; -av_strerror(ff_neterrno(), errbuf, sizeof(errbuf)); +av_strerror(ff_neterror(), errbuf, sizeof(errbuf)); av_log(ctx, level, "%s: %s\n", prefix, errbuf); } diff --git a/libavformat/network.h b/libavformat/network.h index 728c20c9bb..f338694212 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -62,7 +62,7 @@ * @return platform-specific AVERROR value * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ -int ff_ne
[FFmpeg-devel] [PATCH v5 3/6] avformat/network: add ff_neterror2() for cases that don't use WSAGetLastError
For example, WSAStartup()'s documentation says: "A call to the WSAGetLastError function is not needed and should not be used" --- libavformat/network.c | 5 - libavformat/network.h | 6 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/network.c b/libavformat/network.c index 5d0d05c5f1..351dc34bb6 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -123,7 +123,10 @@ void ff_network_close(void) #if HAVE_WINSOCK2_H int ff_neterror(void) { -int err = WSAGetLastError(); +return ff_neterror2(WSAGetLastError()); +} +int ff_neterror2(int err) +{ switch (err) { case WSAEWOULDBLOCK: return AVERROR(EAGAIN); diff --git a/libavformat/network.h b/libavformat/network.h index f338694212..1ac067f09f 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -63,6 +63,12 @@ * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ int ff_neterror(void); +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +int ff_neterror2(int err); #else #include #include -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 4/6] avformat/network: add ff_neterror2() for compatibility with Windows
This is not currently used anywhere, but included to avoid potential future surprises. --- libavformat/network.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavformat/network.h b/libavformat/network.h index 1ac067f09f..7c8f81a050 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -82,6 +82,12 @@ int ff_neterror2(int err); * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ #define ff_neterror() AVERROR(errno) +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +#define ff_neterror2(ERRNO) AVERROR(ERRNO) #endif /* HAVE_WINSOCK2_H */ #if HAVE_ARPA_INET_H -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 5/6] avformat/network: Return 0/AVERROR from ff_network_init()
--- libavformat/avio.c| 7 +-- libavformat/network.c | 7 +++ libavformat/rtsp.c| 14 -- libavformat/rtspdec.c | 5 +++-- libavformat/sapdec.c | 5 +++-- libavformat/sapenc.c | 5 +++-- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index d109f3adff..8c94bfeb14 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -123,8 +123,11 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up, int err; #if CONFIG_NETWORK -if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init()) -return AVERROR(EIO); +if (up->flags & URL_PROTOCOL_FLAG_NETWORK) { +err = ff_network_init(); +if (err<0) +return err; +} #endif if ((flags & AVIO_FLAG_READ) && !up->url_read) { av_log(NULL, AV_LOG_ERROR, diff --git a/libavformat/network.c b/libavformat/network.c index 351dc34bb6..643294efe4 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -59,11 +59,10 @@ int ff_network_init(void) { #if HAVE_WINSOCK2_H WSADATA wsaData; - -if (WSAStartup(MAKEWORD(1,1), &wsaData)) -return 0; +return ff_neterror2(WSAStartup(MAKEWORD(1,1), &wsaData)); +#else +return 0; #endif -return 1; } int ff_network_wait_fd(int fd, int write) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index b0c61ee00a..d50d0b7fc0 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1740,8 +1740,9 @@ int ff_rtsp_connect(AVFormatContext *s) return AVERROR(EINVAL); } -if (!ff_network_init()) -return AVERROR(EIO); +err = ff_network_init(); +if (err<0) +return err; if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = s->iformat ? DEFAULT_REORDERING_DELAY : 0; @@ -2395,8 +2396,9 @@ static int sdp_read_header(AVFormatContext *s) char url[MAX_URL_SIZE]; AVBPrint bp; -if (!ff_network_init()) -return AVERROR(EIO); +err = ff_network_init(); +if (err<0) +return err; if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = DEFAULT_REORDERING_DELAY; @@ -2522,8 +2524,8 @@ static int rtp_read_header(AVFormatContext *s) AVBPrint sdp; AVDictionary *opts = NULL; -if (!ff_network_init()) -return AVERROR(EIO); +if ((ret = ff_network_init())<0) +return ret; opts = map_to_opts(rt); ret = ffurl_open_whitelist(&in, s->url, AVIO_FLAG_READ, diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 10078ce2fa..1b4b478170 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -663,8 +663,9 @@ static int rtsp_listen(AVFormatContext *s) int ret; enum RTSPMethod methodcode; -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; /* extract hostname and port */ av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host), diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 357c0dd514..393e544556 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -70,8 +70,9 @@ static int sap_read_header(AVFormatContext *s) int port; int ret, i; -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, path, sizeof(path), s->url); diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 87a834a8d8..5760e3a0c2 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -80,8 +80,9 @@ static int sap_write_header(AVFormatContext *s) int udp_fd; AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0); -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; /* extract hostname and port */ av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &base_port, -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 6/6] avformat/avformat: Document return codes for av_format_(de)init
--- libavformat/avformat.h | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8afdcd9fd0..f624fb1e2e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1944,12 +1944,16 @@ const char *avformat_license(void); * This function will be deprecated once support for older GnuTLS and * OpenSSL libraries is removed, and this function has no purpose * anymore. + * + * @return 0 for success or AVERROR code */ int avformat_network_init(void); /** * Undo the initialization done by avformat_network_init. Call it only * once for each time you called avformat_network_init. + * + * @return 0 for success or AVERROR code */ int avformat_network_deinit(void); -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Value analysis with Frama-C's Eva plugin (and an UB fix)
On Wed, May 15, 2024 at 09:39:43PM +0200, Tomas Härdin wrote: > Hi > > So as I said in the coverity thread it would be good if we could get at > least part of the codebase covered using formal tools. To this effect I > sat down for an hour just now and gave libavutil/common.h a go with > Frama-C's Eva plugin [1;2]. This plugin performs value analysis, which > is a much simpler analysis compared to say the weakest predicate (WP) > plugin. > > Going through the functions from top to bottom it only took until > av_clipl_int32_c() to find my first UB, a patch for which is attached. > Thus my harping on this has born at least some fruit. > > To run the analysis implemented in this set of patches (all of which > I've attached here because I don't want to bother writing six follow-up > email), first install frama-c using opam. I'm using 28.0~beta (Nickel). > Then run "make verify" in libavutil/ and Eva should tell you that 33% > of functions are covered and 100% of statements in those functions are > covered, with zero alarms. > > If the project isn't interested in this then I'll probably continue > fiddling with it on my own mostly as exercise. But I suspect it will > bear even more fruit in time. > > /Tomas > > [1] https://frama-c.com/ > [2] https://frama-c.com/fc-plugins/eva.html I'm all for automated checks, but in my experience they're only worthwhile if two conditions are met: * they run automatically on a regular basis * their output doesn't get boring One simple way to meet both criteria would be a cron job that runs overnight, and messages the ML with just the issues that didn't exist in yesterday's run. Plenty of other ways to do it, but something like that would be a great start. ___ 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] all: s/Open/Allocate and initialize/ in comments
Comments for a few prominent functions claim to "open" something, when they actually "allocate and initialize" that thing. Using a different word misleads users into thinking it's doing a different thing, making the interface more time-consuming to learn. Replace "open" with the more standard "allocate and initialize". --- libavformat/avformat.h | 4 ++-- libavformat/avio.h | 4 ++-- libavutil/hwcontext.h | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8afdcd9fd0..2fb89807a1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -2235,8 +2235,8 @@ int av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt, unsigned int offset, unsigned int max_probe_size); /** - * Open an input stream and read the header. The codecs are not opened. - * The stream must be closed with avformat_close_input(). + * Allocate and initialize an input stream, then read the header. + * The codecs are not opened. The stream must be closed with avformat_close_input(). * * @param ps Pointer to user-supplied AVFormatContext (allocated by * avformat_alloc_context). May be a pointer to NULL, in diff --git a/libavformat/avio.h b/libavformat/avio.h index ebf611187d..1f56c58f9a 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -330,7 +330,7 @@ const char *avio_find_protocol_name(const char *url); int avio_check(const char *url, int flags); /** - * Open directory for reading. + * Allocate and initialize a directory for reading. * * @param s directory read context. Pointer to a NULL pointer must be passed. * @param url directory to be listed. @@ -707,7 +707,7 @@ int avio_closep(AVIOContext **s); /** - * Open a write only memory stream. + * Allocate and initialize a write only memory stream. * * @param s new IO context * @return zero if no error. diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index bac30debae..be03f565f2 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -264,7 +264,8 @@ AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); int av_hwdevice_ctx_init(AVBufferRef *ref); /** - * Open a device of the specified type and create an AVHWDeviceContext for it. + * Allocate and initialize a device of the specified type, + * and create an AVHWDeviceContext for it. * * This is a convenience function intended to cover the simple cases. Callers * who need to fine-tune device creation/management should open the device -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/opt: Say more often that AV_OPT_SEARCH_CHILDREN searches children first
This behaviour is already mentioned in the documentation for AV_OPT_SEARCH_CHILDREN itself, but that's quite easy to miss. Knowing that child options *override* parent ones is useful for users, so it's worth mentioning in all the places they would look. av_opt_find() had a note that av_opt_find2() was missing. Assume that wasn't deliberate, and copy it over. --- libavutil/opt.h | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavutil/opt.h b/libavutil/opt.h index 07e27a9208..24b807ec66 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -211,7 +211,7 @@ * * The situation is more complicated with nesting. An AVOptions-enabled struct * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag - * to av_opt_find() will make the function search children recursively. + * to av_opt_find() will make the function recursively search children first. * * For enumerating there are basically two cases. The first is when you want to * get all options that may potentially exist on the struct and its children @@ -570,10 +570,11 @@ const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter); * @return A pointer to the option found, or NULL if no option * was found. * - * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable - * directly with av_opt_set(). Use special calls which take an options - * AVDictionary (e.g. avformat_open_input()) to set options found with this - * flag. + * @note If AV_OPT_SEARCH_CHILDREN is set, this function will return an + * option from the first matching child class, or the specified class if + * no child matches. Options from child classes may not be settable directly + * with av_opt_set(), so use special calls which take an options AVDictionary + * (e.g. avformat_open_input()) to set options found with this flag. */ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags); @@ -598,6 +599,12 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, * * @return A pointer to the option found, or NULL if no option * was found. + * + * @note If AV_OPT_SEARCH_CHILDREN is set, this function will return an + * option from the first matching child class, or the specified class if + * no child matches. Options from child classes may not be settable directly + * with av_opt_set(), so use special calls which take an options AVDictionary + * (e.g. avformat_open_input()) to set options found with this flag. */ const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, int opt_flags, int search_flags, void **target_obj); @@ -780,7 +787,8 @@ int av_opt_copy(void *dest, const void *src); * key=value parameters. Values containing ':' special characters must be * escaped. * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN - * is passed here, then the option may be set on a child of obj. + * is passed here, av_opt_set() will set the first matching child if possible, + * or obj if no child matches. * * @return 0 if the value has been set, or an AVERROR code in case of * error: -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC] Value analysis with Frama-C's Eva plugin (and an UB fix)
ons 2024-05-15 klockan 23:29 +0200 skrev Michael Niedermayer: > On Wed, May 15, 2024 at 09:39:43PM +0200, Tomas Härdin wrote: > > Hi > > > > So as I said in the coverity thread it would be good if we could > > get at > > least part of the codebase covered using formal tools. To this > > effect I > > sat down for an hour just now and gave libavutil/common.h a go with > > Frama-C's Eva plugin [1;2]. This plugin performs value analysis, > > which > > is a much simpler analysis compared to say the weakest predicate > > (WP) > > plugin. > > > > Going through the functions from top to bottom it only took until > > av_clipl_int32_c() to find my first UB, a patch for which is > > attached. > > Thus my harping on this has born at least some fruit. > > > > To run the analysis implemented in this set of patches (all of > > which > > I've attached here because I don't want to bother writing six > > follow-up > > email), first install frama-c using opam. I'm using 28.0~beta > > (Nickel). > > Then run "make verify" in libavutil/ and Eva should tell you that > > 33% > > of functions are covered and 100% of statements in those functions > > are > > covered, with zero alarms. > > > > If the project isn't interested in this then I'll probably continue > > fiddling with it on my own mostly as exercise. But I suspect it > > will > > bear even more fruit in time. > > i think this is cool, especially considering > > > > common.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > e451a7cd9a600ece22a6ee85ad7ed0c16349a411 0006-lavu-common.h-Fix- > > UB-in-av_clipl_int32_c.patch > > From 8a535878b9f1f87ca20d5e626f2c4c098b1c948e Mon Sep 17 00:00:00 > > 2001 > > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= > > Date: Wed, 15 May 2024 21:03:47 +0200 > > Subject: [PATCH 6/7] lavu/common.h: Fix UB in av_clipl_int32_c() > > > > --- > > libavutil/common.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/libavutil/common.h b/libavutil/common.h > > index d81131f8ad..0521ebbfc5 100644 > > --- a/libavutil/common.h > > +++ b/libavutil/common.h > > @@ -258,8 +258,8 @@ static av_always_inline av_const int16_t > > av_clip_int16_c(int a) > > */ > > static av_always_inline av_const int32_t av_clipl_int32_c(int64_t > > a) > > { > > - if ((a+0x8000u) & ~UINT64_C(0x)) return > > (int32_t)((a>>63) ^ 0x7FFF); > > - else return > > (int32_t)a; > > + if ((a+UINT64_C(0x8000)) & ~UINT64_C(0x)) return > > (int32_t)((a>>63) ^ 0x7FFF); > > + else return > > (int32_t)a; > > } > > it already found something > > the av_clipl_int32_c patch LGTM Yeah I'll push that patch later today or so if there are no objections. I'll probably keep the rest of them in a fork of my own for now, especially since I'm still learning more about Eva. For example, the ACSL contracts I added to av_log2*() might not actually be necessary /Tomas ___ 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] [RFC] Value analysis with Frama-C's Eva plugin (and an UB fix)
tor 2024-05-16 klockan 13:12 +0100 skrev Andrew Sayers: > On Wed, May 15, 2024 at 09:39:43PM +0200, Tomas Härdin wrote: > > Hi > > > > So as I said in the coverity thread it would be good if we could > > get at > > least part of the codebase covered using formal tools. To this > > effect I > > sat down for an hour just now and gave libavutil/common.h a go with > > Frama-C's Eva plugin [1;2]. This plugin performs value analysis, > > which > > is a much simpler analysis compared to say the weakest predicate > > (WP) > > plugin. > > > > Going through the functions from top to bottom it only took until > > av_clipl_int32_c() to find my first UB, a patch for which is > > attached. > > Thus my harping on this has born at least some fruit. > > > > To run the analysis implemented in this set of patches (all of > > which > > I've attached here because I don't want to bother writing six > > follow-up > > email), first install frama-c using opam. I'm using 28.0~beta > > (Nickel). > > Then run "make verify" in libavutil/ and Eva should tell you that > > 33% > > of functions are covered and 100% of statements in those functions > > are > > covered, with zero alarms. > > > > If the project isn't interested in this then I'll probably continue > > fiddling with it on my own mostly as exercise. But I suspect it > > will > > bear even more fruit in time. > > > > /Tomas > > > > [1] https://frama-c.com/ > > [2] https://frama-c.com/fc-plugins/eva.html > > I'm all for automated checks, but in my experience they're only > worthwhile > if two conditions are met: > > * they run automatically on a regular basis They could easily be incorporated into FATE or a post-commit hook > * their output doesn't get boring The output of Frama-C in general tends to be quite chatty. I've asked a couple of time for them to add exit codes, for example returning with zero only if there are no alarms and no unproven proof obligations. With Eva grepping for " 0 alarms generated by the analysis." is one way, but that's also quite ugly /Tomas ___ 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] [RFC] Value analysis with Frama-C's Eva plugin (and an UB fix)
On Thu, May 16, 2024 at 02:31:31PM +0200, Tomas Härdin wrote: > tor 2024-05-16 klockan 13:12 +0100 skrev Andrew Sayers: > > On Wed, May 15, 2024 at 09:39:43PM +0200, Tomas Härdin wrote: > > > Hi > > > > > > So as I said in the coverity thread it would be good if we could > > > get at > > > least part of the codebase covered using formal tools. To this > > > effect I > > > sat down for an hour just now and gave libavutil/common.h a go with > > > Frama-C's Eva plugin [1;2]. This plugin performs value analysis, > > > which > > > is a much simpler analysis compared to say the weakest predicate > > > (WP) > > > plugin. > > > > > > Going through the functions from top to bottom it only took until > > > av_clipl_int32_c() to find my first UB, a patch for which is > > > attached. > > > Thus my harping on this has born at least some fruit. > > > > > > To run the analysis implemented in this set of patches (all of > > > which > > > I've attached here because I don't want to bother writing six > > > follow-up > > > email), first install frama-c using opam. I'm using 28.0~beta > > > (Nickel). > > > Then run "make verify" in libavutil/ and Eva should tell you that > > > 33% > > > of functions are covered and 100% of statements in those functions > > > are > > > covered, with zero alarms. > > > > > > If the project isn't interested in this then I'll probably continue > > > fiddling with it on my own mostly as exercise. But I suspect it > > > will > > > bear even more fruit in time. > > > > > > /Tomas > > > > > > [1] https://frama-c.com/ > > > [2] https://frama-c.com/fc-plugins/eva.html > > > > I'm all for automated checks, but in my experience they're only > > worthwhile > > if two conditions are met: > > > > * they run automatically on a regular basis > > They could easily be incorporated into FATE or a post-commit hook FATE is a good idea, but post-commit hooks break some workflows. For example, I like to start a test in one window, then put together a commit in another window. I can always amend the commit if there's a problem. The documentation suggests there are some hooks around e-mailing[1], but I haven't tried them. > > > * their output doesn't get boring > > The output of Frama-C in general tends to be quite chatty. I've asked a > couple of time for them to add exit codes, for example returning with > zero only if there are no alarms and no unproven proof obligations. > With Eva grepping for " 0 alarms generated by the analysis." is one > way, but that's also quite ugly Yeah, IMHO the refusal to listen to such reasonable requests is the standard way for these projects to sabotage themselves. Diffing against the previous run tends to work a little better than grepping for a magic word, but still ugly, and you end up having to get rid of line numbers with `sed` or something. I find it's easier to put up with such hacks by constantly reminding myself: No code solution can ever be as ugly as having to do it all by hand. [1] https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_email_hooks ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench
Some timers on certain device and test combinations can produce noisy results, affecting the reliability of performance measurements. One notable example of this is the Canaan K230 RISC-V development board. An option to adjust the number of samples (--samples) has been added, allowing developers to increase or adjust the sample count for more reliable results. Signed-off-by: J. Dekker --- This could also be implemented as a compile time define or a configure argument. tests/checkasm/checkasm.c | 12 +++- tests/checkasm/checkasm.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index ffc89882b1..c31adc3690 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -72,6 +72,9 @@ void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp; #endif +/* Trade-off between speed and accuracy */ +uint64_t bench_runs = 1000; + /* List of tests to invoke */ static const struct { const char *name; @@ -819,7 +822,7 @@ static void bench_uninit(void) static int usage(const char *path) { fprintf(stderr, -"Usage: %s [--bench] [--test=] [--verbose] [seed]\n", +"Usage: %s [--bench] [--samples=] [--test=] [--verbose] [seed]\n", path); return 1; } @@ -866,6 +869,13 @@ int main(int argc, char *argv[]) state.test_name = arg + 7; } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) { state.verbose = 1; +} else if (!strncmp(arg, "--samples=", 10)) { +l = strtoul(arg + 10, &end, 10); +if (*end == '\0') { +bench_runs = l; +} else { +return usage(argv[0]); +} } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX && *end == '\0') { seed = l; diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 07fcc751ff..11f07a919f 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg; static av_unused void *func_ref, *func_new; -#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */ +extern uint64_t bench_runs; /* Decide whether or not the specified function needs to be tested */ #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__)) @@ -339,7 +339,7 @@ typedef struct CheckasmPerf { int ti, tcount = 0;\ uint64_t t = 0; \ checkasm_set_signal_handler_state(1);\ -for (ti = 0; ti < BENCH_RUNS; ti++) {\ +for (ti = 0; ti < bench_runs; ti++) {\ PERF_START(t);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ -- 2.42.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] libsvtav1: Enable 2-pass encoding
Currently, libsvtav1 does not send pass number or stat buffer to SVT-AV1, which means that 2-pass encoding is not possible using FFMPEG; if a user wants to do 2-pass encoding using SVT-AV1, they have to use SvtAv1EncApp. This patch adds 2-pass encoding support to libsvtav1 using the stats buffers provided by the AVCodecContext. When encoding the first pass using SVT-AV1, the following should be logged: Svt[info]: SVT [config]: preset : Pass 1 Indicating that the encoder knows that it is performing the first pass, activating a special preset. With the patch applied: ffmpeg -i input.mp4 -c:v libsvtav1 -an -pass 1 -b:v 1M -f null /dev/null [...] Svt[info]: --- Svt[info]: SVT [config]: preset : Pass 1 Svt[info]: --- [...] Signed-off-by: Fredrik Lundkvist mailto:fredrik.lundkv...@svt.se>> --- libavcodec/libsvtav1.c | 57 +- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 9bc165f0cf..89c932e509 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -25,6 +25,7 @@ #include #include +#include "libavutil/base64.h" #include "libavutil/common.h" #include "libavutil/frame.h" #include "libavutil/imgutils.h" @@ -226,6 +227,37 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->max_qp_allowed = avctx->qmax; param->min_qp_allowed = avctx->qmin; } + +if (avctx->flags & AV_CODEC_FLAG_PASS2) { +int decode_size; +if (!avctx->stats_in) { +av_log(avctx, AV_LOG_ERROR, "No stats file for second pass\n"); +return AVERROR_INVALIDDATA; +} +param->rc_stats_buffer.sz = strlen(avctx->stats_in) * 3 / 4; +param->rc_stats_buffer.buf = av_malloc(param->rc_stats_buffer.sz); +if (!param->rc_stats_buffer.buf) { +av_log(avctx, AV_LOG_ERROR, +"Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed \n", +param->rc_stats_buffer.sz +); +param->rc_stats_buffer.sz = 0; +av_freep(¶m->rc_stats_buffer); +return AVERROR(ENOMEM); +} +decode_size = av_base64_decode(param->rc_stats_buffer.buf, avctx->stats_in, param->rc_stats_buffer.sz); +if (decode_size < 0) { +av_log(avctx, AV_LOG_ERROR, "Stat buffer decode failed\n"); +param->rc_stats_buffer.sz = 0; +av_freep(¶m->rc_stats_buffer); +return AVERROR_INVALIDDATA; +} +param->rc_stats_buffer.sz = decode_size; +param->pass = 2; +} else if (avctx->flags & AV_CODEC_FLAG_PASS1) +param->pass = 1; + + param->max_bit_rate = avctx->rc_max_rate; if ((avctx->bit_rate > 0 || avctx->rc_max_rate > 0) && avctx->rc_buffer_size) param->maximum_buffer_size_ms = @@ -618,6 +650,25 @@ static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt) if (headerPtr->flags & EB_BUFFERFLAG_EOS) { svt_enc->eos_flag = EOS_RECEIVED; svt_av1_enc_release_out_buffer(&headerPtr); + if (avctx->flags & AV_CODEC_FLAG_PASS1) { +SvtAv1FixedBuf first_pass_stats; +EbErrorType svt_ret = svt_av1_enc_get_stream_info(svt_enc->svt_handle, + SVT_AV1_STREAM_INFO_FIRST_PASS_STATS_OUT, + &first_pass_stats); +if (svt_ret == EB_ErrorNone) { +size_t b64_size = AV_BASE64_SIZE(first_pass_stats.sz); + +avctx->stats_out = av_malloc(b64_size); +if (!avctx->stats_out) { +av_log(avctx, AV_LOG_ERROR, "Stat buffer alloc (%"SIZE_SPECIFIER" bytes) failed\n", +b64_size); +return AVERROR(ENOMEM); +} +av_base64_encode(avctx->stats_out, b64_size, first_pass_stats.buf, first_pass_stats.sz); +} else +av_log(avctx, AV_LOG_ERROR, "Failed to get stream info"); + + } return AVERROR_EOF; } #endif @@ -671,7 +722,7 @@ static int eb_receive_packet(AVCodecContext *avctx, AVPacket *pkt) static av_cold int eb_enc_close(AVCodecContext *avctx) { SvtContext *svt_enc = avctx->priv_data; - +EbSvtAv1EncConfiguration *param = &svt_enc->enc_params; if (svt_enc->svt_handle) { svt_av1_enc_deinit(svt_enc->svt_handle); svt_av1_enc_deinit_handle(svt_enc->svt_handle); @@ -682,6 +733,10 @@ static av_cold int eb_enc_close(AVCodecContext *avctx) av_freep(&svt_enc->in_buf); } +if (param->rc_stats_buffer.buf) { +av_freep(¶m->rc_stats_buffer); +} + av_buffer_pool_uninit(&svt_enc->pool); av_frame_free(&svt_enc->frame); ff_dovi_ctx_unref(&svt_enc->dovi); -- 2.39.3 (Apple Git-145) __
Re: [FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench
Le torstaina 16. toukokuuta 2024, 16.09.49 EEST J. Dekker a écrit : > Some timers on certain device and test combinations can produce noisy > results, affecting the reliability of performance measurements. One > notable example of this is the Canaan K230 RISC-V development board. > > An option to adjust the number of samples (--samples) has been added, > allowing developers to increase or adjust the sample count for more > reliable results. IMO, this should pick a reasonable estimate rather than rely on the tester to guess. > > Signed-off-by: J. Dekker > --- > > This could also be implemented as a compile time define or a configure > argument. > > tests/checkasm/checkasm.c | 12 +++- > tests/checkasm/checkasm.h | 4 ++-- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c > index ffc89882b1..c31adc3690 100644 > --- a/tests/checkasm/checkasm.c > +++ b/tests/checkasm/checkasm.c > @@ -72,6 +72,9 @@ > void (*checkasm_checked_call)(void *func, int dummy, ...) = > checkasm_checked_call_novfp; #endif > > +/* Trade-off between speed and accuracy */ > +uint64_t bench_runs = 1000; > + > /* List of tests to invoke */ > static const struct { > const char *name; > @@ -819,7 +822,7 @@ static void bench_uninit(void) > static int usage(const char *path) > { > fprintf(stderr, > -"Usage: %s [--bench] [--test=] [--verbose] [seed]\n", > +"Usage: %s [--bench] [--samples=] [--test=] > [--verbose] [seed]\n", path); > return 1; > } > @@ -866,6 +869,13 @@ int main(int argc, char *argv[]) > state.test_name = arg + 7; > } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) { > state.verbose = 1; > +} else if (!strncmp(arg, "--samples=", 10)) { > +l = strtoul(arg + 10, &end, 10); > +if (*end == '\0') { > +bench_runs = l; > +} else { > +return usage(argv[0]); > +} > } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX && > *end == '\0') { > seed = l; > diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h > index 07fcc751ff..11f07a919f 100644 > --- a/tests/checkasm/checkasm.h > +++ b/tests/checkasm/checkasm.h > @@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg; > > static av_unused void *func_ref, *func_new; > > -#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */ > +extern uint64_t bench_runs; > > /* Decide whether or not the specified function needs to be tested */ > #define check_func(func, ...) (checkasm_save_context(), func_ref = > checkasm_check_func((func_new = func), __VA_ARGS__)) @@ -339,7 +339,7 @@ > typedef struct CheckasmPerf { > int ti, tcount = 0;\ > uint64_t t = 0; \ > checkasm_set_signal_handler_state(1);\ > -for (ti = 0; ti < BENCH_RUNS; ti++) {\ > +for (ti = 0; ti < bench_runs; ti++) {\ The C compiler cannot prove that the global bench_runs is not modified by the tested code. This needs to be cached in an automatic variable. > PERF_START(t);\ > tfunc(__VA_ARGS__);\ > tfunc(__VA_ARGS__);\ -- レミ・デニ-クールモン http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/vvc: fix writing general_constraint_info bytes
The existing implementation was completely broken. Signed-off-by: James Almer --- libavformat/Makefile| 2 +- libavformat/bitstream.c | 1 + libavformat/vvc.c | 33 - tests/ref/fate/source | 1 + 4 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 libavformat/bitstream.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 2d4e0e0c95..211ccf45e5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -727,7 +727,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o # Objects duplicated from other libraries for shared builds -SHLIBOBJS+= log2_tab.o to_upper4.o +SHLIBOBJS+= log2_tab.o to_upper4.o bitstream.o SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= mpegaudiotabs.o SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c new file mode 100644 index 00..2afda37c30 --- /dev/null +++ b/libavformat/bitstream.c @@ -0,0 +1 @@ +#include "libavcodec/bitstream.c" diff --git a/libavformat/vvc.c b/libavformat/vvc.c index 3123cd8d83..f4b8195948 100644 --- a/libavformat/vvc.c +++ b/libavformat/vvc.c @@ -21,6 +21,7 @@ */ #include "libavcodec/get_bits.h" +#include "libavcodec/put_bits.h" #include "libavcodec/golomb.h" #include "libavcodec/vvc.h" #include "libavutil/intreadwrite.h" @@ -45,7 +46,7 @@ typedef struct VVCPTLRecord { uint8_t general_level_idc; uint8_t ptl_frame_only_constraint_flag; uint8_t ptl_multilayer_enabled_flag; -uint8_t general_constraint_info[9]; +uint8_t general_constraint_info[64]; uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1]; uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1]; uint8_t ptl_num_sub_profiles; @@ -138,10 +139,6 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc, vvcc->ptl.num_bytes_constraint_info = 9; memcpy(&vvcc->ptl.general_constraint_info[0], &ptl->gci_general_constraints[0], sizeof(uint8_t) * 9); - -} else { -vvcc->ptl.num_bytes_constraint_info = 1; -memset(&vvcc->ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9); } /* @@ -580,8 +577,6 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc) memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord)); vvcc->lengthSizeMinusOne = 3; // 4 bytes -vvcc->ptl.num_bytes_constraint_info = 1; - vvcc->ptl_present_flag = 1; } @@ -603,7 +598,6 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) { uint8_t i; uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0; -unsigned char *buf = NULL; /* * It's unclear how to properly compute these fields, so * let's always set them to values meaning 'unspecified'. @@ -735,6 +729,10 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8); if (vvcc->ptl_present_flag) { +uint8_t buf[64]; +PutBitContext pbc; + +init_put_bits(&pbc, buf, sizeof(buf)); /* * unsigned int(9) ols_idx; * unsigned int(3) num_sublayers; @@ -766,15 +764,16 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) * unsigned int (1) ptl_frame_only_constraint_flag * unsigned int (1) ptl_multilayer_enabled_flag * unsigned int (8*num_bytes_constraint_info -2) general_constraint_info */ -buf = -(unsigned char *) malloc(sizeof(unsigned char) * - vvcc->ptl.num_bytes_constraint_info); -*buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl. -num_bytes_constraint_info * 8 - 1 | vvcc->ptl. -ptl_multilayer_enabled_flag << vvcc->ptl.num_bytes_constraint_info * -8 - 2 | *vvcc->ptl.general_constraint_info >> 2; -avio_write(pb, buf, vvcc->ptl.num_bytes_constraint_info); -free(buf); + +put_bits(&pbc, 1, vvcc->ptl.ptl_frame_only_constraint_flag); +put_bits(&pbc, 1, vvcc->ptl.ptl_multilayer_enabled_flag); +if (vvcc->ptl.num_bytes_constraint_info) { +ff_copy_bits(&pbc, vvcc->ptl.general_constraint_info, vvcc->ptl.num_bytes_constraint_info - 1); +put_bits(&pbc, 6, vvcc->ptl.general_constraint_info[vvcc->ptl.num_bytes_constraint_info - 1]); +} else +put_bits(&pbc, 6, 0); +flush_put_bits(&pbc); +avio_write(pb, buf, FFMAX(vvcc->ptl.num_bytes_constraint_info, 1)); if (vvcc->num_sublayers > 1) { uint8_t ptl_sublayer_level_present_flags = 0; diff --git a/tests/ref/fate/source b/tests/ref/fate/source index 7b5f14b4f0..d
Re: [FFmpeg-devel] [PATCH 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 16/05/2024 12:26, Andreas Rheinhardt wrote: Lynne via ffmpeg-devel: This commit adds a decoder for the frequency-domain part of USAC. What works: - Mono - Stereo (no prediction) - Stereo (mid/side coding) What doesn't: - Preroll decoding (every single decoder seems faulty or weird?) - Complex stereo prediction Known issues: - Spec incompliance (noise synthesis in particular) - Lack of robustness --- diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index 20545a24d4..3e6592cf0e 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -42,6 +42,8 @@ #include "libavcodec/avcodec.h" #include "libavcodec/mpeg4audio.h" +#include "aacdec_ac.h" + typedef struct AACDecContext AACDecContext; /** @@ -69,6 +71,32 @@ enum CouplingPoint { AFTER_IMDCT = 3, }; +enum AACUsacElem { +ID_USAC_SCE = 0, +ID_USAC_CPE = 1, +ID_USAC_LFE = 2, +ID_USAC_EXT = 3, +}; + +enum ExtensionHeaderType { +ID_CONFIG_EXT_FILL = 0, +ID_CONFIG_EXT_LOUDNESS_INFO = 2, +ID_CONFIG_EXT_STREAM_ID = 7, +}; + +enum AACUsacExtension { +ID_EXT_ELE_FILL, +ID_EXT_ELE_MPEGS, +ID_EXT_ELE_SAOC, +ID_EXT_ELE_AUDIOPREROLL, +ID_EXT_ELE_UNI_DRC, +}; + +enum AACUSACLoudnessExt { +UNIDRCLOUDEXT_TERM = 0x0, +UNIDRCLOUDEXT_EQ = 0x1, +}; + // Supposed to be equal to AAC_RENAME() in case of USE_FIXED. #define RENAME_FIXED(name) name ## _fixed @@ -93,6 +121,40 @@ typedef struct LongTermPrediction { int8_t used[MAX_LTP_LONG_SFB]; } LongTermPrediction; +/* Per channel core mode */ +typedef struct AACUsacElemData { +uint8_t core_mode; +uint8_t scale_factor_grouping; + +/* Timewarping ratio */ +#define NUM_TW_NODES 16 +uint8_t tw_ratio[NUM_TW_NODES]; + +struct { +uint8_t acelp_core_mode : 3; +uint8_t lpd_mode : 5; + +uint8_t bpf_control_info : 1; +uint8_t core_mode_last : 1; +uint8_t fac_data_present : 1; + +int last_lpd_mode; +} ldp; + +struct { +unsigned int seed; +uint8_t level : 3; +uint8_t offset : 5; +} noise; + +struct { +uint8_t gain; +uint32_t kv[8 /* (1024 / 16) / 8 */][8]; +} fac; + +AACArithState ac; +} AACUsacElemData; + /** * Individual Channel Stream */ @@ -145,6 +207,7 @@ typedef struct ChannelCoupling { */ typedef struct SingleChannelElement { IndividualChannelStream ics; +AACUsacElemData ue; ///< USAC element data TemporalNoiseShaping tns; enum BandType band_type[128]; ///< band types int sfo[128]; ///< scalefactor offsets @@ -163,25 +226,141 @@ typedef struct SingleChannelElement { }; } SingleChannelElement; +typedef struct AACUsacStereo { +uint8_t common_window; +uint8_t common_tw; + +uint8_t ms_mask_mode; +uint8_t config_idx; + +struct { +uint8_t use_prev_frame; +uint8_t pred_dir; +uint8_t delta_code_time; +uint8_t pred_used[8][64]; + +AVComplexFloat pred[8][64]; +} cplx; +} AACUsacStereo; + /** * channel element - generic struct for SCE/CPE/CCE/LFE */ typedef struct ChannelElement { int present; // CPE specific +uint8_t max_sfb_ste; ///< (USAC) Maximum of both max_sfb values uint8_t ms_mask[128]; ///< Set if mid/side stereo is used for each scalefactor window band // shared SingleChannelElement ch[2]; // CCE specific ChannelCoupling coup; +// USAC stereo coupling data +AACUsacStereo us; } ChannelElement; +typedef struct AACUSACLoudnessInfo { +uint8_t drc_set_id : 6; +uint8_t downmix_id : 7; +struct { +uint16_t lvl : 12; +uint8_t present : 1; +} sample_peak; + +struct { +uint16_t lvl : 12; +uint8_t measurement : 4; +uint8_t reliability : 2; +uint8_t present : 1; +} true_peak; + +uint8_t nb_measurements : 4; +struct { +uint8_t method_def : 4; +uint8_t method_val; +uint8_t measurement : 4; +uint8_t reliability : 2; +} measurements[16]; +} AACUSACLoudnessInfo; + +typedef struct AACUsacElemConfig { +enum AACUsacElem type; + +uint8_t tw_mdct : 1; +uint8_t noise_fill : 1; + +uint8_t stereo_config_index; + +struct { +int ratio; + +uint8_t harmonic_sbr : 1; /* harmonicSBR */ +uint8_t bs_intertes : 1; /* bs_interTes */ +uint8_t bs_pvc : 1; /* bs_pvc */ + +struct { +uint8_t start_freq; /* dflt_start_freq */ +uint8_t stop_freq; /* dflt_stop_freq */ + +uint8_t freq_scale; /* dflt_freq_scale */ +uint8_t alter_scale : 1; /* dflt_alter_scale */ +uint8_t noise_scale; /* dflt_noise_scale */ + +uint8_t limiter_bands; /* dflt_limiter_bands */ +uint8_t limiter_gains
Re: [FFmpeg-devel] [PATCH v3 1/2] avcodec: add external enc libvvenc for H266/VVC
> On 14. May 2024, at 18:49, Andreas Rheinhardt > wrote: > > Christian Bartnik: >> From: Thomas Siedel >> >> Add external encoder VVenC for H266/VVC encoding. >> Register new encoder libvvenc. >> Add libvvenc to wrap the vvenc interface. >> libvvenc implements encoder option: preset,qp,period,subjopt, >> vvenc-params,levelidc,tier. >> Enable encoder by adding --enable-libvvenc in configure step. >> >> Co-authored-by: Christian Bartnik chris1031...@gmail.com >> Signed-off-by: Christian Bartnik >> --- >> configure | 4 + >> doc/encoders.texi | 65 + >> libavcodec/Makefile| 1 + >> libavcodec/allcodecs.c | 1 + >> libavcodec/libvvenc.c | 566 + >> 5 files changed, 637 insertions(+) >> create mode 100644 libavcodec/libvvenc.c >> >> diff --git a/configure b/configure >> index a909b0689c..5d9a14821b 100755 >> --- a/configure >> +++ b/configure >> @@ -293,6 +293,7 @@ External library support: >> --enable-libvorbis enable Vorbis en/decoding via libvorbis, >>native implementation exists [no] >> --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no] >> + --enable-libvvencenable H.266/VVC encoding via vvenc [no] >> --enable-libwebp enable WebP encoding via libwebp [no] >> --enable-libx264 enable H.264 encoding via x264 [no] >> --enable-libx265 enable HEVC encoding via x265 [no] >> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST=" >> libvmaf >> libvorbis >> libvpx >> +libvvenc >> libwebp >> libxevd >> libxeve >> @@ -3558,6 +3560,7 @@ libvpx_vp8_decoder_deps="libvpx" >> libvpx_vp8_encoder_deps="libvpx" >> libvpx_vp9_decoder_deps="libvpx" >> libvpx_vp9_encoder_deps="libvpx" >> +libvvenc_encoder_deps="libvvenc" >> libwebp_encoder_deps="libwebp" >> libwebp_anim_encoder_deps="libwebp" >> libx262_encoder_deps="libx262" >> @@ -7025,6 +7028,7 @@ enabled libvpx&& { >> die "libvpx enabled but no supported decoders found" >> fi >> } >> +enabled libvvenc && require_pkg_config libvvenc "libvvenc >= >> 1.6.1" "vvenc/vvenc.h" vvenc_get_version >> >> enabled libwebp && { >> enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= >> 0.2.0" webp/encode.h WebPGetEncoderVersion >> diff --git a/doc/encoders.texi b/doc/encoders.texi >> index c82f316f94..92aab17c49 100644 >> --- a/doc/encoders.texi >> +++ b/doc/encoders.texi >> @@ -2378,6 +2378,71 @@ Indicates frame duration >> For more information about libvpx see: >> @url{http://www.webmproject.org/} >> >> +@section libvvenc >> + >> +VVenC H.266/VVC encoder wrapper. >> + >> +This encoder requires the presence of the libvvenc headers and library >> +during configuration. You need to explicitly configure the build with >> +@option{--enable-libvvenc}. >> + >> +The VVenC project website is at >> +@url{https://github.com/fraunhoferhhi/vvenc}. >> + >> +@subsection Supported Pixel Formats >> + >> +VVenC supports only 10-bit color spaces as input. But the internal (encoded) >> +bit depth can be set to 8-bit or 10-bit at runtime. >> + >> +@subsection Options >> + >> +@table @option >> +@item b >> +Sets target video bitrate. >> + >> +@item g >> +Set the GOP size. Currently support for g=1 (Intra only) or default. >> + >> +@item preset >> +Set the VVenC preset. >> + >> +@item levelidc >> +Set level idc. >> + >> +@item tier >> +Set vvc tier. >> + >> +@item qp >> +Set constant quantization parameter. >> + >> +@item subopt @var{boolean} >> +Set subjective (perceptually motivated) optimization. Default is 1 (on). >> + >> +@item bitdepth8 @var{boolean} >> +Set 8bit coding mode instead of using 10bit. Default is 0 (off). >> + >> +@item period >> +set (intra) refresh period in seconds. >> + >> +@item vvenc-params >> +Set vvenc options using a list of @var{key}=@var{value} couples separated >> +by ":". See @command{vvencapp --fullhelp} or @command{vvencFFapp >> --fullhelp} for a list of options. >> + >> +For example, the options might be provided as: >> + >> +@example >> +intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8 >> +@end example >> + >> +For example the encoding options for 2-pass encoding might be provided with >> @option{-vvenc-params}: >> + >> +@example >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params >> passes=2:pass=1:rcstatsfile=stats.json output.mp4 >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params >> passes=2:pass=2:rcstatsfile=stats.json output.mp4 >> +@end example >> + >> +@end table >> + >> @section libwebp >> >> libwebp WebP Image encoder wrapper >> diff --git a/libavcodec/Makefile b/libavcodec/Makefile >> index 2443d2c6fd..5d7349090e 100644 >> --- a/libavcodec/Makefile >> +++ b/libavcodec/Makefile >> @@ -1153,6 +1153,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += >> libvpxdec.o >> OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o >> OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxde
[FFmpeg-devel] [PATCHv4 1/4] lavu/riscv: add assembler macros for adjusting vector LMUL
vtype_vli computes the VTYPE value with the optimal LMUL for a given element width, tail and mask policies and a run-time vector length. vtype_ivli does the same, but with the compile-time constant vector length. vwtypei and vntypei can be used to widen or narrow a VTYPE value for use in mixed-width vector-optimised functions. --- libavutil/riscv/asm.S | 166 +- 1 file changed, 117 insertions(+), 49 deletions(-) diff --git a/libavutil/riscv/asm.S b/libavutil/riscv/asm.S index 14be5055f5..1e6358dcb5 100644 --- a/libavutil/riscv/asm.S +++ b/libavutil/riscv/asm.S @@ -96,77 +96,145 @@ .endm #endif -/* Convenience macro to load a Vector type (vtype) as immediate */ -.macro lvtypei rd, e, m=m1, tp=tu, mp=mu +#if defined (__riscv_v_elen) +# define RV_V_ELEN __riscv_v_elen +#else +/* Run-time detection of the V extension implies ELEN >= 64. */ +# define RV_V_ELEN 64 +#endif +#if RV_V_ELEN == 32 +# define VSEW_MAX 2 +#else +# define VSEW_MAX 3 +#endif -.ifc \e,e8 -.equ ei, 0 +.macro parse_vtype ew, tp, mp +.ifc\ew,e8 +.equvsew, 0 .else -.ifc \e,e16 -.equ ei, 8 +.ifc\ew,e16 +.equvsew, 1 .else -.ifc \e,e32 -.equ ei, 16 +.ifc\ew,e32 +.equvsew, 2 .else -.ifc \e,e64 -.equ ei, 24 +.ifc\ew,e64 +.equvsew, 3 .else -.error "Unknown element type" +.error "Unknown element width \ew" .endif .endif .endif .endif -.ifc \m,m1 -.equ mi, 0 -.else -.ifc \m,m2 -.equ mi, 1 -.else -.ifc \m,m4 -.equ mi, 2 +.ifc\tp,tu +.equtp, 0 .else -.ifc \m,m8 -.equ mi, 3 +.ifc\tp,ta +.equtp, 1 .else -.ifc \m,mf8 -.equ mi, 5 -.else -.ifc \m,mf4 -.equ mi, 6 -.else -.ifc \m,mf2 -.equ mi, 7 -.else -.error "Unknown multiplier" -.equ mi, 3 -.endif -.endif -.endif -.endif -.endif +.error "Unknown tail policy \tp" .endif .endif -.ifc \tp,tu -.equ tpi, 0 +.ifc\mp,mu +.eqump, 0 .else -.ifc \tp,ta -.equ tpi, 64 +.ifc\mp,ma +.eqump, 1 .else -.error "Unknown tail policy" +.error "Unknown mask policy \mp" .endif .endif +.endm -.ifc \mp,mu -.equ mpi, 0 -.else -.ifc \mp,ma -.equ mpi, 128 +/** + * Gets the vector type with the smallest suitable LMUL value. + * @param[out] rd vector type destination register + * @param vl vector length constant + * @param ew element width: e8, e16, e32 or e64 + * @param tp tail policy: tu or ta + * @param mp mask policty: mu or ma + */ +.macro vtype_ivli rd, avl, ew, tp=tu, mp=mu +.if \avl <= 1 +.equlog2vl, 0 +.elseif \avl <= 2 +.equlog2vl, 1 +.elseif \avl <= 4 +.equlog2vl, 2 +.elseif \avl <= 8 +.equlog2vl, 3 +.elseif \avl <= 16 +.equlog2vl, 4 +.elseif \avl <= 32 +.equlog2vl, 5 +.elseif \avl <= 64 +.equlog2vl, 6 +.elseif \avl <= 128 +.equlog2vl, 7 .else -.error "Unknown mask policy" +.error "Vector length \avl out of range" .endif +parse_vtype \ew, \tp, \mp +csrr\rd, vlenb +clz \rd, \rd +addi\rd, \rd, log2vl + 1 + VSEW_MAX - __riscv_xlen +max \rd, \rd, zero // VLMUL must be >= VSEW - VSEW_MAX +.if vsew < VSEW_MAX +addi\rd, \rd, vsew - VSEW_MAX +andi\rd, \rd, 7 .endif +ori \rd, \rd, (vsew << 3) | (tp << 6) | (mp << 7) +.endm + +/** + * Gets the vector type with the smallest suitable LMUL value. + * @param[out] rd vector type destination register + * @param rs vector length source register + * @param[out] tmp temporary register to be clobbered + * @param ew element width: e8, e16, e32 or e64 + * @param tp tail policy: tu or ta + * @param mp mask policty: mu or ma + */ +.macro vtype_vli rd, rs, tmp, ew, tp=tu, mp=mu +parse_vtype \ew, \tp, \mp +/* + * The difference between the CLZ's notionally equals the VLMUL value + * for 4-bit elements. But we want the value for SEW_MAX-bit elements. + */ +slli\tmp, \rs, 1 + VSEW_MAX +csrr\rd, vlenb +addi\tmp, \tmp, -1 +clz \rd, \rd +clz
[FFmpeg-devel] [PATCHv4 2/4] lavc/flacdsp: optimise RVV vector type for lpc16
This calculates the optimal vector type value at run-time based on the hardware vector length and the FLAC LPC prediction order. In this particular case, the additional computation is easily amortised over the loop iterations: T-Head C908: C V before V after 1 48.0214.7 95.2 2 64.7214.2 94.7 3 79.7213.5 94.5 4 96.2196.5 94.2 # 5 111.0195.7118.5 6 127.0211.2102.0 7 143.7194.2101.5 8 175.7193.2101.2 # 9 176.2224.2126.0 10 191.5192.0125.5 11 224.5191.2124.7 12 223.0190.2124.2 13 239.2189.5123.7 14 253.7188.7139.5 15 286.2188.0122.7 16 284.0187.0122.5 # 17 300.2186.5186.5 18 314.0185.5185.7 19 329.7184.7185.0 20 343.0184.2184.2 21 358.7199.2183.7 22 371.7182.7182.7 23 387.5181.7182.0 24 400.7181.0181.2 25 431.5180.2196.5 26 443.7195.5196.0 27 459.0178.7196.2 28 470.7177.7194.2 29 470.0177.0193.5 30 481.2176.2176.5 31 496.2175.5175.7 32 507.2174.7191.0 # # Power of two boundary. With 128-bit vectors, improvements are expected for the first two test cases only. For the other two, there is overhead but below noise. Improvements should be better observable with prediction order of 8 and less, or on hardware with larger vector sizes. The same optimisation strategy should be applicable to LPC32 (and work-in-progress LPC33), but is left as a future exercise. flac lpc16 --- libavcodec/riscv/flacdsp_init.c | 2 +- libavcodec/riscv/flacdsp_rvv.S | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/riscv/flacdsp_init.c b/libavcodec/riscv/flacdsp_init.c index 4f1652dbe7..735aec0691 100644 --- a/libavcodec/riscv/flacdsp_init.c +++ b/libavcodec/riscv/flacdsp_init.c @@ -71,7 +71,7 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { int vlenb = ff_get_rv_vlenb(); -if (vlenb >= 16) +if ((flags & AV_CPU_FLAG_RVB_BASIC) && vlenb >= 16) c->lpc16 = ff_flac_lpc16_rvv; # if (__riscv_xlen >= 64) diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S index 6287faa260..e1a20ce8e1 100644 --- a/libavcodec/riscv/flacdsp_rvv.S +++ b/libavcodec/riscv/flacdsp_rvv.S @@ -20,8 +20,9 @@ #include "libavutil/riscv/asm.S" -func ff_flac_lpc16_rvv, zve32x -vsetvli zero, a2, e32, m8, ta, ma +func ff_flac_lpc16_rvv, zve32x, zbb +vtype_vli t0, a2, t2, e32, ta, ma +vsetvl zero, a2, t0 vle32.v v8, (a1) sub a4, a4, a2 vle32.v v16, (a0) -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCHv4 3/4] lavc/flacdsp: optimise RVV vector type for lpc32
This is pretty much the same as for lpc16, though it only improves half as large prediction orders. With 128-bit vectors, this gives: C V old V new 1 69.2 181.5 95.5 2 107.7 180.7 95.2 3 145.5 180.0 103.5 4 183.0 179.2 102.7 5 220.7 178.5 128.0 6 257.7 194.0 127.5 7 294.5 193.7 126.7 8 331.0 193.0 126.5 Larger prediction orders see no significant changes at that size. --- libavcodec/riscv/flacdsp_init.c | 15 --- libavcodec/riscv/flacdsp_rvv.S | 12 +++- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libavcodec/riscv/flacdsp_init.c b/libavcodec/riscv/flacdsp_init.c index 735aec0691..830ae36534 100644 --- a/libavcodec/riscv/flacdsp_init.c +++ b/libavcodec/riscv/flacdsp_init.c @@ -71,17 +71,18 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { int vlenb = ff_get_rv_vlenb(); -if ((flags & AV_CPU_FLAG_RVB_BASIC) && vlenb >= 16) +if ((flags & AV_CPU_FLAG_RVB_BASIC) && vlenb >= 16) { c->lpc16 = ff_flac_lpc16_rvv; # if (__riscv_xlen >= 64) -if (flags & AV_CPU_FLAG_RVV_I64) { -if (vlenb > 16) -c->lpc32 = ff_flac_lpc32_rvv_simple; -else -c->lpc32 = ff_flac_lpc32_rvv; -} +if (flags & AV_CPU_FLAG_RVV_I64) { +if (vlenb > 16) +c->lpc32 = ff_flac_lpc32_rvv_simple; +else +c->lpc32 = ff_flac_lpc32_rvv; +} # endif +} c->wasted32 = ff_flac_wasted32_rvv; diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S index e1a20ce8e1..2941928465 100644 --- a/libavcodec/riscv/flacdsp_rvv.S +++ b/libavcodec/riscv/flacdsp_rvv.S @@ -76,22 +76,24 @@ func ff_flac_lpc32_rvv, zve64x ret endfunc -func ff_flac_lpc32_rvv_simple, zve64x -vsetivli zero, 1, e64, m1, ta, ma +func ff_flac_lpc32_rvv_simple, zve64x, zbb +vtype_vli t3, a2, t1, e64, ta, ma +vntypei t2, t3 +vsetvl zero, a2, t3 // e64 vmv.s.x v0, zero -vsetvli zero, a2, e32, m4, ta, ma +vsetvl zero, zero, t2 // e32 vle32.v v8, (a1) sub a4, a4, a2 vle32.v v16, (a0) sh2add a0, a2, a0 1: vwmul.vv v24, v8, v16 -vsetvli zero, zero, e64, m8, ta, ma +vsetvl zero, zero, t3 // e64 vredsum.vs v24, v24, v0 lw t0, (a0) addia4, a4, -1 vmv.x.s t1, v24 -vsetvli zero, zero, e32, m4, ta, ma +vsetvl zero, zero, t2 // e32 sra t1, t1, a3 add t0, t0, t1 vslide1down.vx v16, v16, t0 -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCHv4 4/4] lavc/huffyuvdsp: optimise RVV vtype for add_hfyu_left_pred_bgr32
T-Head C908: add_hfyu_left_pred_bgr32_c: 237.5 add_hfyu_left_pred_bgr32_rvv_i32: 173.5 (before) add_hfyu_left_pred_bgr32_rvv_i32: 110.0 (after) --- libavcodec/riscv/huffyuvdsp_rvv.S | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/riscv/huffyuvdsp_rvv.S b/libavcodec/riscv/huffyuvdsp_rvv.S index 9c4434907d..d334f5c6d0 100644 --- a/libavcodec/riscv/huffyuvdsp_rvv.S +++ b/libavcodec/riscv/huffyuvdsp_rvv.S @@ -36,8 +36,10 @@ func ff_add_int16_rvv, zve32x ret endfunc -func ff_add_hfyu_left_pred_bgr32_rvv, zve32x -vsetivli zero, 4, e8, m1, ta, ma +func ff_add_hfyu_left_pred_bgr32_rvv, zve32x, zbb +vtype_ivli t1, 4, e8, ta, ma +li t0, 4 +vsetvl zero, t0, t1 vle8.v v8, (a3) sh2add a2, a2, a1 1: -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCHv4 4/4] lavc/huffyuvdsp: optimise RVV vtype for add_hfyu_left_pred_bgr32
Le torstaina 16. toukokuuta 2024, 19.48.40 EEST Rémi Denis-Courmont a écrit : > T-Head C908: > add_hfyu_left_pred_bgr32_c: 237.5 > add_hfyu_left_pred_bgr32_rvv_i32: 173.5 (before) > add_hfyu_left_pred_bgr32_rvv_i32: 110.0 (after) > --- > libavcodec/riscv/huffyuvdsp_rvv.S | 6 -- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/riscv/huffyuvdsp_rvv.S > b/libavcodec/riscv/huffyuvdsp_rvv.S index 9c4434907d..d334f5c6d0 100644 > --- a/libavcodec/riscv/huffyuvdsp_rvv.S > +++ b/libavcodec/riscv/huffyuvdsp_rvv.S > @@ -36,8 +36,10 @@ func ff_add_int16_rvv, zve32x > ret > endfunc > > -func ff_add_hfyu_left_pred_bgr32_rvv, zve32x > -vsetivli zero, 4, e8, m1, ta, ma > +func ff_add_hfyu_left_pred_bgr32_rvv, zve32x, zbb > +vtype_ivli t1, 4, e8, ta, ma > +li t0, 4 > +vsetvl zero, t0, t1 > vle8.v v8, (a3) > sh2add a2, a2, a1 > 1: Missing Zvbb check in init.c will be added. -- 雷米‧德尼-库尔蒙 http://www.remlab.net/ ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avformat/vvc: fix writing general_constraint_info bytes
The existing implementation was completely broken. Signed-off-by: James Almer --- libavformat/Makefile| 2 +- libavformat/bitstream.c | 1 + libavformat/vvc.c | 28 ++-- tests/ref/fate/source | 1 + 4 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 libavformat/bitstream.c diff --git a/libavformat/Makefile b/libavformat/Makefile index 2d4e0e0c95..211ccf45e5 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -727,7 +727,7 @@ OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o OBJS-$(CONFIG_LIBZMQ_PROTOCOL) += libzmq.o # Objects duplicated from other libraries for shared builds -SHLIBOBJS+= log2_tab.o to_upper4.o +SHLIBOBJS+= log2_tab.o to_upper4.o bitstream.o SHLIBOBJS-$(CONFIG_ISO_MEDIA)+= mpegaudiotabs.o SHLIBOBJS-$(CONFIG_FLV_MUXER)+= mpeg4audio_sample_rates.o SHLIBOBJS-$(CONFIG_HLS_DEMUXER) += ac3_channel_layout_tab.o diff --git a/libavformat/bitstream.c b/libavformat/bitstream.c new file mode 100644 index 00..2afda37c30 --- /dev/null +++ b/libavformat/bitstream.c @@ -0,0 +1 @@ +#include "libavcodec/bitstream.c" diff --git a/libavformat/vvc.c b/libavformat/vvc.c index 3123cd8d83..36d387f295 100644 --- a/libavformat/vvc.c +++ b/libavformat/vvc.c @@ -21,6 +21,7 @@ */ #include "libavcodec/get_bits.h" +#include "libavcodec/put_bits.h" #include "libavcodec/golomb.h" #include "libavcodec/vvc.h" #include "libavutil/intreadwrite.h" @@ -138,9 +139,7 @@ static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc, vvcc->ptl.num_bytes_constraint_info = 9; memcpy(&vvcc->ptl.general_constraint_info[0], &ptl->gci_general_constraints[0], sizeof(uint8_t) * 9); - } else { -vvcc->ptl.num_bytes_constraint_info = 1; memset(&vvcc->ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9); } @@ -580,8 +579,6 @@ static void vvcc_init(VVCDecoderConfigurationRecord *vvcc) memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord)); vvcc->lengthSizeMinusOne = 3; // 4 bytes -vvcc->ptl.num_bytes_constraint_info = 1; - vvcc->ptl_present_flag = 1; } @@ -603,7 +600,6 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) { uint8_t i; uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0; -unsigned char *buf = NULL; /* * It's unclear how to properly compute these fields, so * let's always set them to values meaning 'unspecified'. @@ -735,6 +731,10 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8); if (vvcc->ptl_present_flag) { +uint8_t buf[64]; +PutBitContext pbc; + +init_put_bits(&pbc, buf, sizeof(buf)); /* * unsigned int(9) ols_idx; * unsigned int(3) num_sublayers; @@ -766,15 +766,15 @@ static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc) * unsigned int (1) ptl_frame_only_constraint_flag * unsigned int (1) ptl_multilayer_enabled_flag * unsigned int (8*num_bytes_constraint_info -2) general_constraint_info */ -buf = -(unsigned char *) malloc(sizeof(unsigned char) * - vvcc->ptl.num_bytes_constraint_info); -*buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl. -num_bytes_constraint_info * 8 - 1 | vvcc->ptl. -ptl_multilayer_enabled_flag << vvcc->ptl.num_bytes_constraint_info * -8 - 2 | *vvcc->ptl.general_constraint_info >> 2; -avio_write(pb, buf, vvcc->ptl.num_bytes_constraint_info); -free(buf); +put_bits(&pbc, 1, vvcc->ptl.ptl_frame_only_constraint_flag); +put_bits(&pbc, 1, vvcc->ptl.ptl_multilayer_enabled_flag); +if (vvcc->ptl.num_bytes_constraint_info) { +ff_copy_bits(&pbc, vvcc->ptl.general_constraint_info, (vvcc->ptl.num_bytes_constraint_info - 1) * 8); +put_bits(&pbc, 6, vvcc->ptl.general_constraint_info[vvcc->ptl.num_bytes_constraint_info - 1] & 0x3f); +} else +put_bits(&pbc, 6, 0); +flush_put_bits(&pbc); +avio_write(pb, buf, FFMAX(vvcc->ptl.num_bytes_constraint_info, 1)); if (vvcc->num_sublayers > 1) { uint8_t ptl_sublayer_level_present_flags = 0; diff --git a/tests/ref/fate/source b/tests/ref/fate/source index 7b5f14b4f0..d8d4224145 100644 --- a/tests/ref/fate/source +++ b/tests/ref/fate/source @@ -10,6 +10,7 @@ libavdevice/reverse.c libavfilter/af_arnndn.c libavfilter/file_open.c libavfilter/log2_tab.c +libavformat/bitstream.c libavformat/file_open.c libavformat/golomb_tab.c libavformat/log2_tab.c -- 2.45.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.
Re: [FFmpeg-devel] [PATCH 1/8] aacdec: move from scalefactor ranged arrays to flat arrays
On Thu, May 16, 2024 at 12:08:11PM +0200, Lynne via ffmpeg-devel wrote: > AAC uses an unconventional system to send scalefactors > (the volume+quantization value for each band). > Each window is split into either 1 or 8 blocks (long vs short), > and transformed separately from one another, with the coefficients > for each being also completely independent. The scalefactors > slightly increase from 64 (long) to 128 (short) to accomodate > better per-block-per-band volume for each window. > > To reduce overhead, the codec signals scalefactor sizes in an obtuse way, > where each group's scalefactor types are sent via a variable length decoding, > with a range. > But our decoder was written in a way where those ranges were carried through > the entire decoder, and to actually read them you had to use the range. > > Instead of having a dedicated array with a range for each scalefactor, > just let the decoder directly index each scalefactor. > > This also switches the form of quantized scalefactors to the format > the spec uses, where for intensity stereo and regular, scalefactors > are stored in a scalefactor - 100 form, rather than as-is. > > USAC gets rid of the complex scalefactor handling. This commit permits > for code sharing between both. > --- > libavcodec/aac/Makefile | 3 +- > libavcodec/aac/aacdec.c | 100 --- > libavcodec/aac/aacdec.h | 5 +- > libavcodec/aac/aacdec_dsp_template.c | 95 ++--- > 4 files changed, 85 insertions(+), 118 deletions(-) > > diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile > index c3e525d373..8b0bfff3e5 100644 > --- a/libavcodec/aac/Makefile > +++ b/libavcodec/aac/Makefile > @@ -2,6 +2,7 @@ clean:: > $(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%) > > OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \ > -aac/aacdec_float.o > +aac/aacdec_float.o aac/aacdec_usac.o > \ > +aac/aacdec_ac.o AR libavcodec/libavcodec.a ar: libavcodec/aac/aacdec_ac.o: No such file or directory make: *** [ffbuild/library.mak:38: libavcodec/libavcodec.a] Error 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA 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 1/8] aacdec: move from scalefactor ranged arrays to flat arrays
On 16/05/2024 20:30, Michael Niedermayer wrote: On Thu, May 16, 2024 at 12:08:11PM +0200, Lynne via ffmpeg-devel wrote: AAC uses an unconventional system to send scalefactors (the volume+quantization value for each band). Each window is split into either 1 or 8 blocks (long vs short), and transformed separately from one another, with the coefficients for each being also completely independent. The scalefactors slightly increase from 64 (long) to 128 (short) to accomodate better per-block-per-band volume for each window. To reduce overhead, the codec signals scalefactor sizes in an obtuse way, where each group's scalefactor types are sent via a variable length decoding, with a range. But our decoder was written in a way where those ranges were carried through the entire decoder, and to actually read them you had to use the range. Instead of having a dedicated array with a range for each scalefactor, just let the decoder directly index each scalefactor. This also switches the form of quantized scalefactors to the format the spec uses, where for intensity stereo and regular, scalefactors are stored in a scalefactor - 100 form, rather than as-is. USAC gets rid of the complex scalefactor handling. This commit permits for code sharing between both. --- libavcodec/aac/Makefile | 3 +- libavcodec/aac/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 4 files changed, 85 insertions(+), 118 deletions(-) diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile index c3e525d373..8b0bfff3e5 100644 --- a/libavcodec/aac/Makefile +++ b/libavcodec/aac/Makefile @@ -2,6 +2,7 @@ clean:: $(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%) OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \ -aac/aacdec_float.o +aac/aacdec_float.o aac/aacdec_usac.o \ +aac/aacdec_ac.o AR libavcodec/libavcodec.a ar: libavcodec/aac/aacdec_ac.o: No such file or directory make: *** [ffbuild/library.mak:38: libavcodec/libavcodec.a] Error 1 Thanks, a stray git add, fixed in my repo OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Added alpha layer support v2
From 8b62312d794ecb66cc1a8dbe4933fca0d725057b Mon Sep 17 00:00:00 2001 From: Andrea Mastroberti <10736...@polimi.it> Date: Fri, 17 May 2024 00:29:01 +0200 Subject: [PATCH] avfilter/smartblur: Added alpha layer support --- doc/filters.texi | 20 +- libavfilter/version.h | 3 ++- libavfilter/vf_smartblur.c | 43 +++--- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 8230661261..f5bf475d13 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -22653,9 +22653,27 @@ whether a pixel should be blurred or not. The option value must be an integer in the range [-30,30]. A value of 0 will filter all the image, a value included in [0,30] will filter flat areas and a value included in [-30,0] will filter edges. Default value is @option{luma_threshold}. + +@item alpha_radius, ar +Set the alpha radius. The option value must be a float number in +the range [0.1,5.0] that specifies the variance of the gaussian filter +used to blur the image (slower if larger). Default value is @option{luma_radius}. + +@item alpha_strength, as +Set the alpha strength. The option value must be a float number +in the range [-1.0,1.0] that configures the blurring. A value included +in [0.0,1.0] will blur the image whereas a value included in +[-1.0,0.0] will sharpen the image. Default value is @option{luma_strength}. + +@item alpha_threshold, at +Set the alpha threshold used as a coefficient to determine +whether a pixel should be blurred or not. The option value must be an +integer in the range [-30,30]. A value of 0 will filter all the image, +a value included in [0,30] will filter flat areas and a value included +in [-30,0] will filter edges. Default value is @option{luma_threshold}. @end table -If a chroma option is not explicitly set, the corresponding luma value +If a chroma or alpha option is not explicitly set, the corresponding luma value is set. @section sobel diff --git a/libavfilter/version.h b/libavfilter/version.h index 408c700767..ba0c6b3862 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,8 +31,9 @@ #include "version_major.h" + #define LIBAVFILTER_VERSION_MINOR 2 -#define LIBAVFILTER_VERSION_MICRO 101 +#define LIBAVFILTER_VERSION_MICRO 102 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_smartblur.c b/libavfilter/vf_smartblur.c index ae0ec05b2d..dbbb74339d 100644 --- a/libavfilter/vf_smartblur.c +++ b/libavfilter/vf_smartblur.c @@ -54,6 +54,7 @@ typedef struct SmartblurContext { const AVClass *class; FilterParam luma; FilterParam chroma; +FilterParam alpha; int hsub; int vsub; unsigned int sws_flags; @@ -77,6 +78,13 @@ static const AVOption smartblur_options[] = { { "chroma_threshold", "set chroma threshold", OFFSET(chroma.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS }, { "ct", "set chroma threshold", OFFSET(chroma.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS }, +{ "alpha_radius","set alpha radius",OFFSET(alpha.radius),AV_OPT_TYPE_FLOAT, {.dbl=RADIUS_MIN-1}, RADIUS_MIN-1, RADIUS_MAX, .flags=FLAGS }, +{ "ar" , "set alpha radius",OFFSET(alpha.radius),AV_OPT_TYPE_FLOAT, {.dbl=RADIUS_MIN-1}, RADIUS_MIN-1, RADIUS_MAX, .flags=FLAGS }, +{ "alpha_strength", "set alpha strength", OFFSET(alpha.strength), AV_OPT_TYPE_FLOAT, {.dbl=STRENGTH_MIN-1}, STRENGTH_MIN-1, STRENGTH_MAX, .flags=FLAGS }, +{ "as", "set alpha strength", OFFSET(alpha.strength), AV_OPT_TYPE_FLOAT, {.dbl=STRENGTH_MIN-1}, STRENGTH_MIN-1, STRENGTH_MAX, .flags=FLAGS }, +{ "alpha_threshold", "set alpha threshold", OFFSET(alpha.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS }, +{ "at", "set alpha threshold", OFFSET(alpha.threshold), AV_OPT_TYPE_INT, {.i64=THRESHOLD_MIN-1}, THRESHOLD_MIN-1, THRESHOLD_MAX, .flags=FLAGS }, + { NULL } }; @@ -94,15 +102,24 @@ static av_cold int init(AVFilterContext *ctx) if (s->chroma.threshold < THRESHOLD_MIN) s->chroma.threshold = s->luma.threshold; -s->luma.quality = s->chroma.quality = 3.0; +/* make alpha default to luma values, if not explicitly set */ +if (s->alpha.radius < RADIUS_MIN) +s->alpha.radius = s->luma.radius; +if (s->alpha.strength < STRENGTH_MIN) +s->alpha.strength = s->luma.strength; +if (s->alpha.threshold < THRESHOLD_MIN) +s->alpha.threshold = s->luma.threshold; + +s->luma.quality = s->chroma.quality = s->alpha.quality = 3.0; s->sws_flags = SWS_BICUBIC; av_log(ctx, AV_LOG_VERBOSE, "luma_radius:%f luma_strength:%f luma_threshold:%d " - "chroma_radius:%f chroma_strength:%f chro
[FFmpeg-devel] [PATCH 1/5] avcodec/rv34: assert that size is not 0 in rv34_gen_vlc_ext()
Helps: CID1548380 Uninitialized scalar variable Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/rv34.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 23a570bb807..4ce0cc58d05 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -98,6 +98,8 @@ static av_cold void rv34_gen_vlc_ext(const uint8_t *bits, int size, VLC *vlc, uint16_t cw[MAX_VLC_SIZE]; int maxbits; +av_assert0(size > 0); + for (int i = 0; i < size; i++) counts[bits[i]]++; -- 2.43.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 2/5] avcodec/scpr3: unify adding 127
Untested, i have no testcase nor does fate Signed-off-by: Michael Niedermayer --- libavcodec/scpr3.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 5271717ac79..79106ddcff8 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -42,7 +42,7 @@ static void renew_table3(uint32_t nsym, uint32_t *cntsum, freqs[d] = b; freqs1[d] = a; cnts[d] = c; -for (int q = a + 128 - 1 >> 7, f = (a + b - 1 >> 7) + 1; q < f; q++) +for (int q = a + 127 >> 7, f = a + b + 127 >> 7; q < f; q++) dectab[q] = d; a += b; @@ -232,7 +232,7 @@ static int update_model6_to_7(PixelModel3 *m) cnts[j] = d; } p = (e + 127) >> 7; -k = ((f + e - 1) >> 7) + 1; +k = f + e + 127 >> 7; if (k > FF_ARRAY_ELEMS(n.dectab)) return AVERROR_INVALIDDATA; for (i = 0; i < k - p; i++) @@ -688,10 +688,10 @@ static int update_model3_to_7(PixelModel3 *m, uint8_t value) n.cntsum += n.cnts[e]; n.freqs1[e] = c; g = n.freqs[e]; -f = (c + g - 1 >> 7) + 1; +f = c + g + 127 >> 7; if (f > FF_ARRAY_ELEMS(n.dectab)) return AVERROR_INVALIDDATA; -for (q = c + 128 - 1 >> 7; q < f; q++) { +for (q = c + 127 >> 7; q < f; q++) { n.dectab[q] = e; } c += g; @@ -760,7 +760,7 @@ static int decode_value3(SCPRContext *s, uint32_t max, uint32_t *cntsum, freqs1[i] = e; g = (c + 127) >> 7; c += e; -q = ((c - 1) >> 7) + 1; +q = c + 127 >> 7; if (q > g) { for (int j = 0; j < q - g; j++) dectable[j + g] = i; -- 2.43.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 3/5] avcodec/scpr3: Check add_dec() for failure
Fixes: CID1441459 Improper use of negative value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/scpr3.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/scpr3.c b/libavcodec/scpr3.c index 79106ddcff8..45706123db0 100644 --- a/libavcodec/scpr3.c +++ b/libavcodec/scpr3.c @@ -465,6 +465,8 @@ static int decode_adaptive6(PixelModel3 *m, uint32_t code, uint32_t *value, return 0; grow_dec(m); c = add_dec(m, q, g, f); +if (c < 0) +return AVERROR_INVALIDDATA; } incr_cntdec(m, c); @@ -868,11 +870,11 @@ static int decode_unit3(SCPRContext *s, PixelModel3 *m, uint32_t code, uint32_t sync_code3(gb, rc); break; case 6: -if (!decode_adaptive6(m, code, value, &a, &b)) { +ret = decode_adaptive6(m, code, value, &a, &b); +if (!ret) ret = update_model6_to_7(m); -if (ret < 0) -return AVERROR_INVALIDDATA; -} +if (ret < 0) +return ret; decode3(gb, rc, a, b); sync_code3(gb, rc); break; -- 2.43.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 4/5] avcodec/sga: Check non constant init_get_bits8()
Fixes: CID1473562 Unchecked return value Fixes: CID1473592 Unchecked return value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/sga.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavcodec/sga.c b/libavcodec/sga.c index 0f42cf912b2..aca941e057e 100644 --- a/libavcodec/sga.c +++ b/libavcodec/sga.c @@ -254,11 +254,14 @@ static int decode_palmapdata(AVCodecContext *avctx) const int bits = (s->nb_pal + 1) / 2; GetByteContext *gb = &s->gb; GetBitContext pm; +int ret; bytestream2_seek(gb, s->palmapdata_offset, SEEK_SET); if (bytestream2_get_bytes_left(gb) < s->palmapdata_size) return AVERROR_INVALIDDATA; -init_get_bits8(&pm, gb->buffer, s->palmapdata_size); +ret = init_get_bits8(&pm, gb->buffer, s->palmapdata_size); +if (ret < 0) +return ret; for (int y = 0; y < s->tiles_h; y++) { uint8_t *dst = s->palmapindex_data + y * s->tiles_w; @@ -277,11 +280,14 @@ static int decode_tiledata(AVCodecContext *avctx) SGAVideoContext *s = avctx->priv_data; GetByteContext *gb = &s->gb; GetBitContext tm; +int ret; bytestream2_seek(gb, s->tiledata_offset, SEEK_SET); if (bytestream2_get_bytes_left(gb) < s->tiledata_size) return AVERROR_INVALIDDATA; -init_get_bits8(&tm, gb->buffer, s->tiledata_size); +ret = init_get_bits8(&tm, gb->buffer, s->tiledata_size); +if (ret < 0) +return ret; for (int n = 0; n < s->nb_tiles; n++) { uint8_t *dst = s->tileindex_data + n * 64; -- 2.43.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 5/5] avcodec/tests/dct: Use 64bit in intermediate for error computation
Fixes: CID1500284 Unintentional integer overflow Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer --- libavcodec/tests/dct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/tests/dct.c b/libavcodec/tests/dct.c index 010d0c1ac35..17a08144597 100644 --- a/libavcodec/tests/dct.c +++ b/libavcodec/tests/dct.c @@ -226,8 +226,8 @@ static int dct_error(const struct algo *dct, int test, int is_idct, int speed, c v = abs(err); if (v > err_inf) err_inf = v; -err2_matrix[i] += v * v; -err2 += v * v; +err2_matrix[i] += v * (int64_t)v; +err2 += v * (int64_t)v; sysErr[i] += block[i] - block1[i]; blockSumErr += v; if (abs(block[i]) > maxout) -- 2.43.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] lavu/version: fix minor version
From: Haihao Xiang The latest version should be 59.18.100 since commit 01c5f4ad $ git diff 01c5f4ad~1..HEAD doc/APIchanges ... +2024-05-10 - x - lavu 59.18.100 - cpu.h + Add AV_CPU_FLAG_RV_ZVBB. + Signed-off-by: Haihao Xiang --- libavutil/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/version.h b/libavutil/version.h index 3b5a2e7aaa..b9b9baf98c 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 17 +#define LIBAVUTIL_VERSION_MINOR 18 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libsvtav1: Enable 2-pass encoding
To continue this discussion. >> +av_base64_encode(avctx->stats_out, b64_size, >> first_pass_stats.buf, first_pass_stats.sz); > Unchecked return value. I don’t see any non-test instance in the code base where the return value of av_base64_encode is actually checked. Unchecked calls are however found in many places, f.ex. libaomenc, librav1e, and matroskadec. IMO it should be consistent across the code base, and thus stay as is in this patch. /Fredrik ___ 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] web: add a news entry about STF sponsorship
On 15.05.24 20:51, Thilo Borgmann via ffmpeg-devel wrote: On 15.05.24 18:39, Rémi Denis-Courmont wrote: Le tiistaina 14. toukokuuta 2024, 20.12.31 EEST Thilo Borgmann via ffmpeg-devel a écrit : --- This text including the link is also meant to be published via our socal media. src/index | 8 1 file changed, 8 insertions(+) diff --git a/src/index b/src/index index d035ffa..83cc9bf 100644 --- a/src/index +++ b/src/index @@ -35,6 +35,14 @@ News + May 13th, 2024, Sovereign Tech Fund + + The FFMPEG community is excited to announce that it has received + funding from the href="https://www.sovereigntechfund.de/";>Sovereign Tech Fund + for the maintenance of the FFMPEG project. This funding will help ensure that FFMPEG + continues bringing video efficiently and securely to billions worldwide everyday. + Lexical repeation is poor style, TBH: "...funding from Fund ... This funding..." "The FFmpeg community is excited to announce that Germany's Sovereign Tech Fund has become its first governmental sponsor. Their support will help sustain the maintainance of the FFmpeg project, a critical open-source software multimedia component essential to bringing audio and video to billions around the world everyday." I like it. I'd want to post this text in an updated patch tomorrow morning, if there are no more remarks. Pushed like that. Thanks, Thilo ___ 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 v4 0/5] avformat/network: improve ff_neterrno()
I've prepended two patches - one with just the documentation, the other with just the code. The latter was generated automatically with the command specified in the commit message, so e.g. rebase conflicts can be resolved by throwing away the old commit and rerunning the command. As discussed, this also fixes the assigns in if-statements. ___ 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 v4 1/5] Add documentation for ff_neterrno()
--- libavformat/network.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libavformat/network.h b/libavformat/network.h index ca214087fc..728c20c9bb 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -57,6 +57,11 @@ #define getsockopt(a, b, c, d, e) getsockopt(a, b, c, (char*) d, e) #define setsockopt(a, b, c, d, e) setsockopt(a, b, c, (const char*) d, e) +/* + * @brief AVERROR for the latest network function + * @return platform-specific AVERROR value + * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) + */ int ff_neterrno(void); #else #include @@ -65,6 +70,11 @@ int ff_neterrno(void); #include #include +/* + * @brief AVERROR for the latest network function + * @return platform-specific AVERROR value + * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) + */ #define ff_neterrno() AVERROR(errno) #endif /* HAVE_WINSOCK2_H */ -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 2/5] Rename "ff_neterrno()" to "ff_neterror()"
This function does not check errno on Windows, so the old name was misleading. Actual command: sed -i -e 's/ff_neterrno/ff_neterror/g' $( git grep -l ff_neterrno ) --- libavformat/network.c | 24 libavformat/network.h | 4 ++-- libavformat/rtpproto.c | 8 libavformat/sctp.c | 10 +- libavformat/tcp.c | 8 libavformat/udp.c | 32 libavformat/unix.c | 6 +++--- libavformat/url.h | 2 +- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/libavformat/network.c b/libavformat/network.c index f752efc411..5d0d05c5f1 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -72,7 +72,7 @@ int ff_network_wait_fd(int fd, int write) struct pollfd p = { .fd = fd, .events = ev, .revents = 0 }; int ret; ret = poll(&p, 1, POLLING_TIME); -return ret < 0 ? ff_neterrno() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN); +return ret < 0 ? ff_neterror() : p.revents & (ev | POLLERR | POLLHUP) ? 0 : AVERROR(EAGAIN); } int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb) @@ -121,7 +121,7 @@ void ff_network_close(void) } #if HAVE_WINSOCK2_H -int ff_neterrno(void) +int ff_neterror(void) { int err = WSAGetLastError(); switch (err) { @@ -168,7 +168,7 @@ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout, ret = poll(p, nfds, POLLING_TIME); if (ret != 0) { if (ret < 0) -ret = ff_neterrno(); +ret = ff_neterror(); if (ret == AVERROR(EINTR)) continue; break; @@ -217,11 +217,11 @@ int ff_listen(int fd, const struct sockaddr *addr, } ret = bind(fd, addr, addrlen); if (ret) -return ff_neterrno(); +return ff_neterror(); ret = listen(fd, 1); if (ret) -return ff_neterrno(); +return ff_neterror(); return ret; } @@ -236,7 +236,7 @@ int ff_accept(int fd, int timeout, URLContext *h) ret = accept(fd, NULL, NULL); if (ret < 0) -return ff_neterrno(); +return ff_neterror(); if (ff_socket_nonblock(ret, 1) < 0) av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); @@ -267,7 +267,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr, av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); while ((ret = connect(fd, addr, addrlen))) { -ret = ff_neterrno(); +ret = ff_neterror(); switch (ret) { case AVERROR(EINTR): if (ff_check_interrupt(&h->interrupt_callback)) @@ -280,7 +280,7 @@ int ff_listen_connect(int fd, const struct sockaddr *addr, return ret; optlen = sizeof(ret); if (getsockopt (fd, SOL_SOCKET, SO_ERROR, &ret, &optlen)) -ret = AVUNERROR(ff_neterrno()); +ret = AVUNERROR(ff_neterror()); if (ret != 0) { char errbuf[100]; ret = AVERROR(ret); @@ -365,7 +365,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, attempt->fd = ff_socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol, h); if (attempt->fd < 0) -return ff_neterrno(); +return ff_neterror(); attempt->deadline_us = av_gettime_relative() + timeout_ms * 1000; attempt->addr = ai; @@ -381,7 +381,7 @@ static int start_connect_attempt(struct ConnectionAttempt *attempt, } while ((ret = connect(attempt->fd, ai->ai_addr, ai->ai_addrlen))) { -ret = ff_neterrno(); +ret = ff_neterror(); switch (ret) { case AVERROR(EINTR): if (ff_check_interrupt(&h->interrupt_callback)) { @@ -478,7 +478,7 @@ int ff_connect_parallel(struct addrinfo *addrs, int timeout_ms_per_address, // a successful connection or an error). optlen = sizeof(last_err); if (getsockopt(attempts[i].fd, SOL_SOCKET, SO_ERROR, &last_err, &optlen)) -last_err = ff_neterrno(); +last_err = ff_neterror(); else if (last_err != 0) last_err = AVERROR(last_err); if (last_err == 0) { @@ -587,6 +587,6 @@ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname) void ff_log_net_error(void *ctx, int level, const char* prefix) { char errbuf[100]; -av_strerror(ff_neterrno(), errbuf, sizeof(errbuf)); +av_strerror(ff_neterror(), errbuf, sizeof(errbuf)); av_log(ctx, level, "%s: %s\n", prefix, errbuf); } diff --git a/libavformat/network.h b/libavformat/network.h index 728c20c9bb..f338694212 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -62,7 +62,7 @@ * @return platform-specific AVERROR value * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ -int ff_ne
[FFmpeg-devel] [PATCH v4 3/5] avformat/network: add ff_neterror2() for cases where we already have an error
For example, WSAStartup()'s documentation says: "A call to the WSAGetLastError function is not needed and should not be used" --- libavformat/network.c | 5 - libavformat/network.h | 12 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libavformat/network.c b/libavformat/network.c index 5d0d05c5f1..351dc34bb6 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -123,7 +123,10 @@ void ff_network_close(void) #if HAVE_WINSOCK2_H int ff_neterror(void) { -int err = WSAGetLastError(); +return ff_neterror2(WSAGetLastError()); +} +int ff_neterror2(int err) +{ switch (err) { case WSAEWOULDBLOCK: return AVERROR(EAGAIN); diff --git a/libavformat/network.h b/libavformat/network.h index f338694212..7c8f81a050 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -63,6 +63,12 @@ * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ int ff_neterror(void); +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +int ff_neterror2(int err); #else #include #include @@ -76,6 +82,12 @@ int ff_neterror(void); * @note Error is based on WSAGetLastError() (Windows) or `errno` (otherwise) */ #define ff_neterror() AVERROR(errno) +/* + * @brief ff_neterror()-style AVERROR + * @param err error code (usually an errno or Windows Sockets Error Code) + * @note Windows Sockets Error Codes are only supported in Windows + */ +#define ff_neterror2(ERRNO) AVERROR(ERRNO) #endif /* HAVE_WINSOCK2_H */ #if HAVE_ARPA_INET_H -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 4/5] avformat/network: Return 0/AVERROR from ff_network_init()
--- libavformat/avio.c| 7 +-- libavformat/network.c | 7 +++ libavformat/rtsp.c| 14 -- libavformat/rtspdec.c | 5 +++-- libavformat/sapdec.c | 5 +++-- libavformat/sapenc.c | 5 +++-- 6 files changed, 25 insertions(+), 18 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index d109f3adff..8c94bfeb14 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -123,8 +123,11 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up, int err; #if CONFIG_NETWORK -if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init()) -return AVERROR(EIO); +if (up->flags & URL_PROTOCOL_FLAG_NETWORK) { +err = ff_network_init(); +if (err<0) +return err; +} #endif if ((flags & AVIO_FLAG_READ) && !up->url_read) { av_log(NULL, AV_LOG_ERROR, diff --git a/libavformat/network.c b/libavformat/network.c index 351dc34bb6..643294efe4 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -59,11 +59,10 @@ int ff_network_init(void) { #if HAVE_WINSOCK2_H WSADATA wsaData; - -if (WSAStartup(MAKEWORD(1,1), &wsaData)) -return 0; +return ff_neterror2(WSAStartup(MAKEWORD(1,1), &wsaData)); +#else +return 0; #endif -return 1; } int ff_network_wait_fd(int fd, int write) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index b0c61ee00a..d50d0b7fc0 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1740,8 +1740,9 @@ int ff_rtsp_connect(AVFormatContext *s) return AVERROR(EINVAL); } -if (!ff_network_init()) -return AVERROR(EIO); +err = ff_network_init(); +if (err<0) +return err; if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = s->iformat ? DEFAULT_REORDERING_DELAY : 0; @@ -2395,8 +2396,9 @@ static int sdp_read_header(AVFormatContext *s) char url[MAX_URL_SIZE]; AVBPrint bp; -if (!ff_network_init()) -return AVERROR(EIO); +err = ff_network_init(); +if (err<0) +return err; if (s->max_delay < 0) /* Not set by the caller */ s->max_delay = DEFAULT_REORDERING_DELAY; @@ -2522,8 +2524,8 @@ static int rtp_read_header(AVFormatContext *s) AVBPrint sdp; AVDictionary *opts = NULL; -if (!ff_network_init()) -return AVERROR(EIO); +if ((ret = ff_network_init())<0) +return ret; opts = map_to_opts(rt); ret = ffurl_open_whitelist(&in, s->url, AVIO_FLAG_READ, diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index 10078ce2fa..1b4b478170 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -663,8 +663,9 @@ static int rtsp_listen(AVFormatContext *s) int ret; enum RTSPMethod methodcode; -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; /* extract hostname and port */ av_url_split(proto, sizeof(proto), auth, sizeof(auth), host, sizeof(host), diff --git a/libavformat/sapdec.c b/libavformat/sapdec.c index 357c0dd514..393e544556 100644 --- a/libavformat/sapdec.c +++ b/libavformat/sapdec.c @@ -70,8 +70,9 @@ static int sap_read_header(AVFormatContext *s) int port; int ret, i; -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, path, sizeof(path), s->url); diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index 87a834a8d8..5760e3a0c2 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -80,8 +80,9 @@ static int sap_write_header(AVFormatContext *s) int udp_fd; AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0); -if (!ff_network_init()) -return AVERROR(EIO); +ret = ff_network_init(); +if (ret<0) +return ret; /* extract hostname and port */ av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &base_port, -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 5/5] avformat/avformat: Document return codes for av_format_(de)init
--- libavformat/avformat.h | 4 1 file changed, 4 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8afdcd9fd0..f624fb1e2e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1944,12 +1944,16 @@ const char *avformat_license(void); * This function will be deprecated once support for older GnuTLS and * OpenSSL libraries is removed, and this function has no purpose * anymore. + * + * @return 0 for success or AVERROR code */ int avformat_network_init(void); /** * Undo the initialization done by avformat_network_init. Call it only * once for each time you called avformat_network_init. + * + * @return 0 for success or AVERROR code */ int avformat_network_deinit(void); -- 2.43.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 0/8] aacdec: add a native xHE-AAC decoder
This commit adds a decoder for the frequency-domain part of USAC. What works: - Mono - Stereo (no prediction) - Stereo (mid/side coding) What doesn't: - Preroll decoding (every single decoder seems faulty or weird?) - Complex stereo prediction Known issues: - Spec incompliance due to the spec being flat-out wrong in 11 cases. - Spec compliance due to the spec being woefully underspecified. - Lack of robustness - A single memory leak in packet fragmentation. I've reached out to the spec authors to get a conformation. I'm reasonably happy with the way I integrated it to send it off for review ahead of spec issue clarification. Lynne (8): aacdec: move from scalefactor ranged arrays to flat arrays aacdec: expose channel layout related functions aacdec: expose decode_tns aacdec_dsp: implement 768-point transform and windowing aactab: add deemphasis tables for USAC aactab: add tables for the new USAC arithmetic coder aactab: add new scalefactor offset tables for 96/768pt windows aacdec: add a decoder for AAC USAC (xHE-AAC) libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 364 libavcodec/aac/aacdec.h | 211 - libavcodec/aac/aacdec_ac.c | 224 + libavcodec/aac/aacdec_ac.h | 54 ++ libavcodec/aac/aacdec_dsp_template.c | 162 ++-- libavcodec/aac/aacdec_fixed.c|2 + libavcodec/aac/aacdec_float.c|4 + libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 192 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1230 ++ libavcodec/aac/aacdec_usac.h | 47 + libavcodec/aactab.c | 523 +++ libavcodec/aactab.h | 15 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + 17 files changed, 2850 insertions(+), 234 deletions(-) create mode 100644 libavcodec/aac/aacdec_ac.c create mode 100644 libavcodec/aac/aacdec_ac.h create mode 100644 libavcodec/aac/aacdec_lpd.c create mode 100644 libavcodec/aac/aacdec_lpd.h create mode 100644 libavcodec/aac/aacdec_usac.c create mode 100644 libavcodec/aac/aacdec_usac.h -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/8] aacdec: move from scalefactor ranged arrays to flat arrays
AAC uses an unconventional system to send scalefactors (the volume+quantization value for each band). Each window is split into either 1 or 8 blocks (long vs short), and transformed separately from one another, with the coefficients for each being also completely independent. The scalefactors slightly increase from 64 (long) to 128 (short) to accomodate better per-block-per-band volume for each window. To reduce overhead, the codec signals scalefactor sizes in an obtuse way, where each group's scalefactor types are sent via a variable length decoding, with a range. But our decoder was written in a way where those ranges were carried through the entire decoder, and to actually read them you had to use the range. Instead of having a dedicated array with a range for each scalefactor, just let the decoder directly index each scalefactor. This also switches the form of quantized scalefactors to the format the spec uses, where for intensity stereo and regular, scalefactors are stored in a scalefactor - 100 form, rather than as-is. USAC gets rid of the complex scalefactor handling. This commit permits for code sharing between both. --- libavcodec/aac/Makefile | 3 +- libavcodec/aac/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 4 files changed, 85 insertions(+), 118 deletions(-) diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile index c3e525d373..8b0bfff3e5 100644 --- a/libavcodec/aac/Makefile +++ b/libavcodec/aac/Makefile @@ -2,6 +2,7 @@ clean:: $(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%) OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \ -aac/aacdec_float.o +aac/aacdec_float.o aac/aacdec_usac.o \ +aac/aacdec_ac.o OBJS-$(CONFIG_AAC_FIXED_DECODER)+= aac/aacdec.o aac/aacdec_tab.o \ aac/aacdec_fixed.o diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 7457fe6c97..35722f9b9b 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1412,13 +1412,13 @@ fail: * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], - int band_type_run_end[120], GetBitContext *gb, - IndividualChannelStream *ics) +static int decode_band_types(AACDecContext *ac, SingleChannelElement *sce, + GetBitContext *gb) { -int g, idx = 0; +IndividualChannelStream *ics = &sce->ics; const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; -for (g = 0; g < ics->num_window_groups; g++) { + +for (int g = 0; g < ics->num_window_groups; g++) { int k = 0; while (k < ics->max_sfb) { uint8_t sect_end = k; @@ -1442,10 +1442,8 @@ static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], return AVERROR_INVALIDDATA; } } while (sect_len_incr == (1 << bits) - 1); -for (; k < sect_end; k++) { -band_type[idx] = sect_band_type; -band_type_run_end[idx++] = sect_end; -} +for (; k < sect_end; k++) +sce->band_type[g*ics->max_sfb + k] = sect_band_type; } } return 0; @@ -1461,69 +1459,59 @@ static int decode_band_types(AACDecContext *ac, enum BandType band_type[120], * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_scalefactors(AACDecContext *ac, int sfo[120], - GetBitContext *gb, - unsigned int global_gain, - IndividualChannelStream *ics, - enum BandType band_type[120], - int band_type_run_end[120]) +static int decode_scalefactors(AACDecContext *ac, SingleChannelElement *sce, + GetBitContext *gb, unsigned int global_gain) { -int g, i, idx = 0; +IndividualChannelStream *ics = &sce->ics; int offset[3] = { global_gain, global_gain - NOISE_OFFSET, 0 }; int clipped_offset; int noise_flag = 1; -for (g = 0; g < ics->num_window_groups; g++) { -for (i = 0; i < ics->max_sfb;) { -int run_end = band_type_run_end[idx]; -switch (band_type[idx]) { + +for (int g = 0; g < ics->num_window_groups; g++) { +for (int sfb = 0; sfb < ics->max_sfb; sfb++) { +switch (sce->band_type[g*ics->max_sfb + sfb]) { case ZERO_BT: -for (; i < run_end; i++, idx++) -sfo[idx] = 0; +sce->sfo[g*ics->max_sfb + sfb] = 0; break;
[FFmpeg-devel] [PATCH 3/8] aacdec: expose decode_tns
USAC has the same syntax, with one minor change we can check for. --- libavcodec/aac/aacdec.c | 6 +++--- libavcodec/aac/aacdec.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 40554ff9e4..a7e5b2a369 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1542,7 +1542,7 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb, * * @return Returns error status. 0 - OK, !0 - error */ -static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, +int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics) { int w, filt, i, coef_len, coef_res, coef_compress; @@ -1690,7 +1690,7 @@ int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, } tns->present = get_bits1(gb); if (tns->present && !er_syntax) { -ret = decode_tns(ac, tns, gb, ics); +ret = ff_aac_decode_tns(ac, tns, gb, ics); if (ret < 0) goto fail; } @@ -1704,7 +1704,7 @@ int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, // I see no textual basis in the spec for this occurring after SSR gain // control, but this is what both reference and real implmentations do if (tns->present && er_syntax) { -ret = decode_tns(ac, tns, gb, ics); +ret = ff_aac_decode_tns(ac, tns, gb, ics); if (ret < 0) goto fail; } diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index f54618aaa9..303e285c81 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -351,6 +351,9 @@ int ff_aac_decode_init_fixed(AVCodecContext *avctx); int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce, GetBitContext *gb, int common_window, int scale_flag); +int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, + GetBitContext *gb, const IndividualChannelStream *ics); + int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t (*layout_map)[3], int *tags, -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/8] aacdec: expose channel layout related functions
--- libavcodec/aac/aacdec.c | 73 - libavcodec/aac/aacdec.h | 19 +-- 2 files changed, 51 insertions(+), 41 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 35722f9b9b..40554ff9e4 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -111,10 +111,6 @@ Parametric Stereo. */ -static int output_configure(AACDecContext *ac, -uint8_t layout_map[MAX_ELEM_ID*4][3], int tags, -enum OCStatus oc_type, int get_new_frame); - #define overread_err "Input buffer exhausted before END element found\n" static int count_channels(uint8_t (*layout)[3], int tags) @@ -447,8 +443,8 @@ static void pop_output_configuration(AACDecContext *ac) if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) { ac->oc[1] = ac->oc[0]; ac->avctx->ch_layout = ac->oc[1].ch_layout; -output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, - ac->oc[1].status, 0); +ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, +ac->oc[1].status, 0); } } @@ -458,7 +454,7 @@ static void pop_output_configuration(AACDecContext *ac) * * @return Returns error status. 0 - OK, !0 - error */ -static int output_configure(AACDecContext *ac, +int ff_aac_output_configure(AACDecContext *ac, uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags, enum OCStatus oc_type, int get_new_frame) { @@ -547,7 +543,7 @@ static av_cold void flush(AVCodecContext *avctx) * * @return Returns error status. 0 - OK, !0 - error */ -static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, +int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, uint8_t (*layout_map)[3], int *tags, int channel_config) @@ -587,7 +583,7 @@ static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx, return 0; } -static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) +ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id) { /* For PCE based channel configurations map the channels solely based * on tags. */ @@ -603,11 +599,11 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n"); -if (set_default_channel_config(ac, ac->avctx, layout_map, - &layout_map_tags, 2) < 0) +if (ff_aac_set_default_channel_config(ac, ac->avctx, layout_map, + &layout_map_tags, 2) < 0) return NULL; -if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) +if (ff_aac_output_configure(ac, layout_map, layout_map_tags, +OC_TRIAL_FRAME, 1) < 0) return NULL; ac->oc[1].m4ac.chan_config = 2; @@ -627,8 +623,8 @@ static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id) layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT; layout_map[0][1] = 0; layout_map[1][1] = 1; -if (output_configure(ac, layout_map, layout_map_tags, - OC_TRIAL_FRAME, 1) < 0) +if (ff_aac_output_configure(ac, layout_map, layout_map_tags, +OC_TRIAL_FRAME, 1) < 0) return NULL; if (ac->oc[1].m4ac.sbr) @@ -877,8 +873,8 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, if (tags < 0) return tags; } else { -if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) +if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, + &tags, channel_config))) return ret; } @@ -887,7 +883,7 @@ static int decode_ga_specific_config(AACDecContext *ac, AVCodecContext *avctx, } else if (m4ac->sbr == 1 && m4ac->ps == -1) m4ac->ps = 1; -if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) +if (ac && (ret = ff_aac_output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0))) return ret; if (extension_flag) { @@ -967,11 +963,11 @@ static int decode_eld_specific_config(AACDecContext *ac, AVCodecContext *avctx, skip_bits_long(gb, 8 * len); } -if ((ret = set_default_channel_config(ac, avctx, layout_map, - &tags, channel_config))) +if ((ret = ff_aac_set_default_channel_config
[FFmpeg-devel] [PATCH 4/8] aacdec_dsp: implement 768-point transform and windowing
Required for USAC --- libavcodec/aac/aacdec.c | 4 ++ libavcodec/aac/aacdec.h | 5 +++ libavcodec/aac/aacdec_dsp_template.c | 67 libavcodec/aac/aacdec_fixed.c| 2 + libavcodec/aac/aacdec_float.c| 4 ++ libavcodec/sinewin_fixed_tablegen.c | 2 + libavcodec/sinewin_fixed_tablegen.h | 4 ++ 7 files changed, 88 insertions(+) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index a7e5b2a369..6f37ac5361 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1113,10 +1113,12 @@ static av_cold int decode_close(AVCodecContext *avctx) } } +av_tx_uninit(&ac->mdct96); av_tx_uninit(&ac->mdct120); av_tx_uninit(&ac->mdct128); av_tx_uninit(&ac->mdct480); av_tx_uninit(&ac->mdct512); +av_tx_uninit(&ac->mdct768); av_tx_uninit(&ac->mdct960); av_tx_uninit(&ac->mdct1024); av_tx_uninit(&ac->mdct_ltp); @@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx) if (ret < 0) \ return ret +MDCT_INIT(ac->mdct96, ac->mdct96_fn, 96, 1.0/96); MDCT_INIT(ac->mdct120, ac->mdct120_fn, 120, 1.0/120); MDCT_INIT(ac->mdct128, ac->mdct128_fn, 128, 1.0/128); MDCT_INIT(ac->mdct480, ac->mdct480_fn, 480, 1.0/480); MDCT_INIT(ac->mdct512, ac->mdct512_fn, 512, 1.0/512); +MDCT_INIT(ac->mdct768, ac->mdct768_fn, 768, 1.0/768); MDCT_INIT(ac->mdct960, ac->mdct960_fn, 960, 1.0/960); MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024); #undef MDCT_INIT diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index 303e285c81..20545a24d4 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -245,6 +245,7 @@ typedef struct AACDecDSP { ChannelElement *cce, int index); void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce); +void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement *sce); void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement *sce); @@ -290,18 +291,22 @@ struct AACDecContext { * @name Computed / set up during initialization * @{ */ +AVTXContext *mdct96; AVTXContext *mdct120; AVTXContext *mdct128; AVTXContext *mdct480; AVTXContext *mdct512; +AVTXContext *mdct768; AVTXContext *mdct960; AVTXContext *mdct1024; AVTXContext *mdct_ltp; +av_tx_fn mdct96_fn; av_tx_fn mdct120_fn; av_tx_fn mdct128_fn; av_tx_fn mdct480_fn; av_tx_fn mdct512_fn; +av_tx_fn mdct768_fn; av_tx_fn mdct960_fn; av_tx_fn mdct1024_fn; av_tx_fn mdct_ltp_fn; diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c index e69970472c..59a69d88f3 100644 --- a/libavcodec/aac/aacdec_dsp_template.c +++ b/libavcodec/aac/aacdec_dsp_template.c @@ -383,6 +383,71 @@ static void AAC_RENAME(imdct_and_windowing)(AACDecContext *ac, SingleChannelElem } } +/** + * Conduct IMDCT and windowing for 768-point frames. + */ +static void AAC_RENAME(imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement *sce) +{ +IndividualChannelStream *ics = &sce->ics; +INTFLOAT *in= sce->AAC_RENAME(coeffs); +INTFLOAT *out = sce->AAC_RENAME(output); +INTFLOAT *saved = sce->AAC_RENAME(saved); +const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); +const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_long_768) : AAC_RENAME(sine_768); +const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96); +INTFLOAT *buf = ac->AAC_RENAME(buf_mdct); +INTFLOAT *temp = ac->AAC_RENAME(temp); +int i; + +// imdct +if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { +for (i = 0; i < 8; i++) +ac->mdct96_fn(ac->mdct96, buf + i * 96, in + i * 96, sizeof(INTFLOAT)); +} else { +ac->mdct768_fn(ac->mdct768, buf, in, sizeof(INTFLOAT)); +} + +/* window overlapping + * NOTE: To simplify the overlapping code, all 'meaningless' short to long + * and long to short transitions are considered to be short to short + * transitions. This leaves just two cases (long to long and short to short) + * with a little special sauce for EIGHT_SHORT_SEQUENCE. + */ + +if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || ics->window_sequence[1] == LONG_STOP_SEQUENCE) && +(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || ics->window_sequence[0] == LONG_START_SEQUENCE)) { +ac->fdsp->vector_fmul_window(out, saved, bu
[FFmpeg-devel] [PATCH 5/8] aactab: add deemphasis tables for USAC
--- libavcodec/aactab.c | 25 + libavcodec/aactab.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 3718b81a07..8ce5e43974 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -3377,3 +3377,28 @@ const DECLARE_ALIGNED(32, int, ff_aac_eld_window_480_fixed)[1800] = { 0xffecff1c, 0xffed391e, 0xffed740c, 0xffedafb1, 0xffedebe1, 0xffee287d, 0xffee654e, 0xffeea23f, }; + +/* As specified by ISO/IEC 23003 */ +#define USAC_EMPH_COEFF 0.68 + +DECLARE_ALIGNED(16, const float, ff_aac_deemph_weights)[16] = { +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +0, +USAC_EMPH_COEFF, +USAC_EMPH_COEFF*USAC_EMPH_COEFF, + +0, +0, +0, +USAC_EMPH_COEFF, +}; diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h index e1a2d8b9a1..91262380d4 100644 --- a/libavcodec/aactab.h +++ b/libavcodec/aactab.h @@ -64,6 +64,8 @@ DECLARE_ALIGNED(32, extern const float, ff_aac_eld_window_480)[1800]; DECLARE_ALIGNED(32, extern const int, ff_aac_eld_window_480_fixed)[1800]; // @} +extern const float ff_aac_deemph_weights[16]; + /* Initializes data shared between float decoder and encoder. */ void ff_aac_float_common_init(void); -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/8] aactab: add tables for the new USAC arithmetic coder
--- libavcodec/aactab.c | 376 libavcodec/aactab.h | 6 + 2 files changed, 382 insertions(+) diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c index 8ce5e43974..dfb2dfd98d 100644 --- a/libavcodec/aactab.c +++ b/libavcodec/aactab.c @@ -1193,6 +1193,382 @@ const uint16_t *const ff_aac_codebook_vector_idx[] = { codebook_vector10_idx, }; +const uint16_t ff_aac_ac_msb_cdfs[64][17] = { +{ 708, 706, 579, 569, 568, 567, 479, 469, +297, 138,97,91,72,52,38,34, 0, }, +{ 7619, 6917, 6519, 6412, 5514, 5003, 4683, 4563, + 3907, 3297, 3125, 3060, 2904, 2718, 2631, 2590, 0, }, +{ 7263, 4888, 4810, 4803, 1889, 415, 335, 327, +195,72,52,49,36,20,15,14, 0, }, +{ 3626, 2197, 2188, 2187, 582,57,47,46, + 30,12, 9, 8, 6, 4, 3, 2, 0, }, +{ 7806, 5541, 5451, 5441, 2720, 834, 691, 674, +487, 243, 179, 167, 139,98,77,70, 0, }, +{ 6684, 4101, 4058, 4055, 1748, 426, 368, 364, +322, 257, 235, 232, 228, 222, 217, 215, 0, }, +{ 9162, 5964, 5831, 5819, 3269, 866, 658, 638, +535, 348, 258, 244, 234, 214, 195, 186, 0, }, +{ 10638, 8491, 8365, 8351, 4418, 2067, 1859, 1834, + 1190, 601, 495, 478, 356, 217, 174, 164, 0, }, +{ 13389, 10514, 10032, 9961, 7166, 3488, 2655, 2524, + 2015, 1140, 760, 672, 585, 426, 325, 283, 0, }, +{ 14861, 12788, 12115, 11952, 9987, 6657, 5323, 4984, + 4324, 3001, 2205, 1943, 1764, 1394, 1115, 978, 0, }, +{ 12876, 10004, 9661, 9610, 7107, 3435, 2711, 2595, + 2257, 1508, 1059, 952, 893, 753, 609, 538, 0, }, +{ 15125, 13591, 13049, 12874, 11192, 8543, 7406, 7023, + 6291, 4922, 4104, 3769, 3465, 2890, 2486, 2275, 0, }, +{ 14574, 13106, 12731, 12638, 10453, 7947, 7233, 7037, + 6031, 4618, 4081, 3906, 3465, 2802, 2476, 2349, 0, }, +{ 15070, 13179, 12517, 12351, 10742, 7657, 6200, 5825, + 5264, 3998, 3014, 2662, 2510, 2153, 1799, 1564, 0, }, +{ 15542, 14466, 14007, 13844, 12489, 10409, 9481, 9132, + 8305, 6940, 6193, 5867, 5458, 4743, 4291, 4047, 0, }, +{ 15165, 14384, 14084, 13934, 12911, 11485, 10844, 10513, + 10002, 8993, 8380, 8051, 7711, 7036, 6514, 6233, 0, }, +{ 15642, 14279, 13625, 13393, 12348, 9971, 8405, 7858, + 7335, 6119, 4918, 4376, 4185, 3719, 3231, 2860, 0, }, +{ 13408, 13407, 11471, 11218, 11217, 11216, 9473, 9216, + 6480, 3689, 2857, 2690, 2256, 1732, 1405, 1302, 0, }, +{ 16098, 15584, 15191, 14931, 14514, 13578, 12703, 12103, + 11830, 11172, 10475, 9867, 9695, 9281, 8825, 8389, 0, }, +{ 15844, 14873, 14277, 13996, 13230, 11535, 10205, 9543, + 9107, 8086, 7085, 6419, 6214, 5713, 5195, 4731, 0, }, +{ 16131, 15720, 15443, 15276, 14848, 13971, 13314, 12910, + 12591, 11874, 11225, 10788, 10573, 10077, 9585, 9209, 0, }, +{ 16331, 16330, 12283, 11435, 11434, 11433, 8725, 8049, + 6065, 4138, 3187, 2842, 2529, 2171, 1907, 1745, 0, }, +{ 16011, 15292, 14782, 14528, 14008, 12767, 11556, 10921, + 10591, 9759, 8813, 8043, 7855, 7383, 6863, 6282, 0, }, +{ 16380, 16379, 15159, 14610, 14609, 14608, 12859, 12111, + 11046, 9536, 8348, 7713, 7216, 6533, 5964, 5546, 0, }, +{ 16367, 16333, 16294, 16253, 16222, 16143, 16048, 15947, + 15915, 15832, 15731, 15619, 15589, 15512, 15416, 15310, 0, }, +{ 15967, 15319, 14937, 14753, 14010, 12638, 11787, 11360, + 10805, 9706, 8934, 8515, 8166, 7456, 6911, 6575, 0, }, +{ 4906, 3005, 2985, 2984, 875, 102,83,81, + 47,17,12,11, 8, 5, 4, 3, 0, }, +{ 7217, 4346, 4269, 4264, 1924, 428, 340, 332, +280, 203, 179, 175, 171, 164, 159, 157, 0, }, +{ 16010, 15415, 15032, 14805, 14228, 13043, 12168, 11634, + 11265, 10419, 9645, 9110, 8892, 8378, 7850, 7437, 0, }, +{ 8573, 5218, 5046, 5032, 2787, 771, 555, 533, +443, 286, 218, 205, 197, 181, 168, 162, 0, }, +{ 11474, 8095, 7822, 7796, 4632, 1443, 1046, 1004, +748, 351, 218, 194, 167, 121,93,83, 0, }, +{ 16152, 15764, 15463, 15264, 14925, 14189, 13536, 13070, + 12846, 12314, 11763, 11277, 11131, 10777, 10383, 10011, 0, }, +{ 14187, 11654, 11043, 10919, 8498, 4885, 3778, 3552, + 2947, 1835, 1283, 1134, 998, 749, 585, 514, 0, }, +{ 14162, 11527, 10759, 10557, 8601, 5417, 4105, 3753, + 3286, 2353, 1708, 1473, 1370, 1148, 959, 840, 0, }, +{ 16205, 15902, 15669, 15498, 15213, 14601, 14068, 13674, +