[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 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_ba
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 v2 0/8] aacdec: add a native xHE-AAC decoder
This patch adds support for the frequency domain part of the xHE-AAC standard (ISO/IEC 23003-3). The speech synthesis support is to be implemented with a later patch. LPD is left as a stub with most bitstream parsing complete. The DRC support is left up for discussion. The DRC system is pretty much exactly ReplayGain2's system, so we may want to expose it and be left for users to implement. Validation does depend on DRC, however, so if we did it externally, we'd still need a filter. Changes from V1: - Preroll implemented - Complex stereo implemented - More robustness and bitstream validation - Surround/multichannel support - Desync fixes 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 | 371 +++--- libavcodec/aac/aacdec.h | 219 +++- libavcodec/aac/aacdec_ac.c | 208 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 | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1587 ++ libavcodec/aac/aacdec_usac.h | 39 + libavcodec/aactab.c | 560 + libavcodec/aactab.h | 22 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + 17 files changed, 3247 insertions(+), 235 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 v2 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/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 3 files changed, 83 insertions(+), 117 deletions(-) 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; case INTENSITY_BT: /* fallthrough */ case INTENSITY_BT2: -for (; i < run_end; i++, idx++) { -offset[2] += get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - SCALE_DIFF_ZERO; -clipped_offset = av_clip(offset[2], -155, 100); -if (offset[2] != clipped_offset) { -avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset);
[FFmpeg-devel] [PATCH v2 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 v2 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 bea0578e92..499bd8eefc 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 v2 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 499bd8eefc..8d1eb74066 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 v2 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 v2 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 v2 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, +
[FFmpeg-devel] [PATCH v2 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) - Stereo (complex prediction) What's left: - Speech coding Known issues: - Desync with certain sequences - Preroll crossover missing (shouldn't matter, bitrate adaptation only) --- libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 188 +-- libavcodec/aac/aacdec.h | 187 +++ libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1587 ++ libavcodec/aac/aacdec_usac.h | 39 + libavcodec/aactab.c | 42 + libavcodec/aactab.h | 10 + 13 files changed, 2491 insertions(+), 76 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 c3e525d373..70b1dca274 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 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..2b8322fc68 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 re
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 19/05/2024 21:39, Marton Balint wrote: On Sun, 19 May 2024, Lynne via ffmpeg-devel wrote: This commit adds a decoder for the frequency-domain part of USAC. [...] +/* Finish later */ +static const enum AVChannel usac_ch_pos_to_av[64] = { + [0] = AV_CHAN_FRONT_LEFT, + [1] = AV_CHAN_FRONT_RIGHT, + [2] = AV_CHAN_FRONT_CENTER, + [3] = AV_CHAN_LOW_FREQUENCY, + [4] = AV_CHAN_BACK_LEFT, // unsure + [5] = AV_CHAN_BACK_RIGHT, // unsure + [6] = AV_CHAN_FRONT_LEFT_OF_CENTER, + [7] = AV_CHAN_FRONT_RIGHT_OF_CENTER, + [8] = 0, /* rear surround left is missing */ + [9] = 0, /* rear surround right is missing */ + [10] = AV_CHAN_BACK_CENTER, + [11] = AV_CHAN_SURROUND_DIRECT_LEFT, + [12] = AV_CHAN_SURROUND_DIRECT_RIGHT, + [13] = AV_CHAN_SIDE_LEFT, // fairly sure + [14] = AV_CHAN_SIDE_RIGHT, // fairly sure + [15] = AV_CHAN_WIDE_LEFT, // somewhat confident + [16] = AV_CHAN_WIDE_RIGHT, // somewhat confident + [17] = AV_CHAN_TOP_FRONT_LEFT, + [18] = AV_CHAN_TOP_FRONT_RIGHT, + [19] = AV_CHAN_TOP_FRONT_CENTER, + [20] = AV_CHAN_TOP_BACK_LEFT, + [21] = AV_CHAN_TOP_BACK_RIGHT, + [22] = AV_CHAN_TOP_BACK_CENTER, + [23] = AV_CHAN_TOP_SIDE_LEFT, + [24] = AV_CHAN_TOP_SIDE_RIGHT, + [25] = AV_CHAN_TOP_CENTER, + [26] = AV_CHAN_LOW_FREQUENCY, // actually LFE2 + [27] = AV_CHAN_BOTTOM_FRONT_LEFT, + [28] = AV_CHAN_BOTTOM_FRONT_RIGHT, + [29] = AV_CHAN_BOTTOM_FRONT_CENTER, + [30] = 0, /* top left surround is missing */ + [31] = 0, /* top right surround is missing */ +}; Some comment would be nice about the source of this table (which document, which table). It looks very similar to the ISO channel positons used in mov_chan. I think we follow this mapping in most cases: Left Surround is SIDE_LEFT Right Surround is SIDE_RIGHT Rear Surround Left is BACK_LEFT Rear Surround Right is BACK_RIGHT So in your table [4] and [5] should be SIDE, [8] and [9] should be BACK. [26] can be AV_CHAN_LOW_FREQUENCY_2, we do have that. Yes, Left/Right Surround and Left/Right Side Surround will be the same, but those are not present in commonly used layouts at the same time. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Source of the table is ISO/IEC 23003-3, Table 74 — bsOutputChannelPos: 0 L left front FL front left 1 R right front FR front right 2 C center front FC front centre 3 LFE low frequency enhancement LFE1 low frequency effects-1 4 Ls left surround LS left surround 5 Rs right surround RS right surround 6 Lc left front center FLc front left centre 7 Rc right front center FRc front right centre 8 Lsr rear surround left BL back left 9 Rsr rear surround right BR back right 10 Cs rear center BC back centre 11 Lsd left surround direct LSd left surround direct 12 Rsd right surround direct RSd right surround direct 13 Lss left side surround SL side left 14 Rss right side surround SR side right 15 Lw left wide front FLw front left wide 16 Rw right wide front FRw front right wide 17 Lv left front vertical height TpFL top front left 18 Rv right front vertical height TpFR top front right 19 Cv center front vertical height TpFC top front centre 20 Lvr left surround vertical height rear TpBL top back left 21 Rvr right surround vertical height rear TpBR top back right 22 Cvr center vertical height rear TpBC top back centre 23 Lvss left vertical height side surround TpSiL top side left 24 Rvss right vertical height side surround TpSiR top side right 25 Ts top center surround TpC top centre 26 LFE2 low frequency enhancement 2 LFE2 low frequency effects-2 27 Lb left front vertical bottom BtFL bottom front left 28 Rb right front vertical bottom BtFR bottom front right 29 Cb center front vertical bottom BtFC bottom front centre 30 Lvs left vertical height surround TpLS top left surround 31 Rvs right vertical height surround TpRS top right surround Third field is "Loudspeaker position", last field is "Loudspeaker position according to IEC 100/1706/CDV/IEC 62574 (TC100)", each prefixed with an abbreviation. I've added the source to the table comment in the code. I've also fixed the SIDE/BACK/LFE2 issue in my github repo I linked earlier. Thanks. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 20/05/2024 01:19, Michael Niedermayer wrote: On Sun, May 19, 2024 at 06:54:44PM +0200, Lynne via ffmpeg-devel wrote: This commit adds a decoder for the frequency-domain part of USAC. What works: - Mono - Stereo (no prediction) - Stereo (mid/side coding) - Stereo (complex prediction) What's left: - Speech coding Known issues: - Desync with certain sequences - Preroll crossover missing (shouldn't matter, bitrate adaptation only) --- libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 188 +-- libavcodec/aac/aacdec.h | 187 +++ libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1587 ++ libavcodec/aac/aacdec_usac.h | 39 + libavcodec/aactab.c | 42 + libavcodec/aactab.h | 10 + 13 files changed, 2491 insertions(+), 76 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 seems to break fate make -j32 fate-source TESTsource --- ./tests/ref/fate/source 2024-05-20 01:14:59.40702 +0200 +++ tests/data/fate/source 2024-05-20 01:17:32.661142354 +0200 @@ -23,6 +25,7 @@ compat/djgpp/math.h compat/float/float.h compat/float/limits.h +libavcodec/aac/aacdec_ac.h libavcodec/bitstream_template.h tools/decode_simple.h Use of av_clip() where av_clip_uintp2() could be used: Test source failed. Look at tests/data/fate/source.err for details. make: *** [tests/Makefile:311: fate-source] Error 1 thx [...] ___ 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". Fixed: -#ifndef AVCODEC_AACDEC_AC_H -#define AVCODEC_AACDEC_AC_H +#ifndef AVCODEC_AAC_AACDEC_AC_H +#define AVCODEC_AAC_AACDEC_AC_H Thanks 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] fate: add tests for xHE-AAC
Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. --- Samples and references: https://files.lynne.ee/xhe_refs/ tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fate: add tests for xHE-AAC
On 21/05/2024 09:18, Paul B Mahol wrote: On Tue, May 21, 2024 at 4:05 AM Lynne via ffmpeg-devel mailto:ffmpeg-devel@ffmpeg.org>> wrote: Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. Sorry for my ignorance, but is such copy allowed from them? --- Samples and references: https://files.lynne.ee/xhe_refs/ <https://files.lynne.ee/xhe_refs/> tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org <mailto:ffmpeg-devel@ffmpeg.org> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel> To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org <mailto:ffmpeg-devel-requ...@ffmpeg.org> with subject "unsubscribe". We have code from very big movie productions that people still buy BDs of and go to the cinema, and you're worried about the ISO noticing that we're hosting a small set of samples (which anyone can download) to test machines? https://standards.iso.org/iso-iec/23003/-3/ed-2/en/ OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] checkasm: add sample argument to adjust during bench
On 21/05/2024 14:32, J. Dekker wrote: 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 --- Auto-detection can be added later when either a count is omitted or a specific value or term such as '0' or 'auto' is provided. This is a development tool, the users will be developers primarily working on master who follow checkasm changes and/ or add their own tests and functionality; there's no need to support a feature like this or deprecate it for years if a better solution is submitted. tests/checkasm/checkasm.c | 12 +++- tests/checkasm/checkasm.h | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 31ca9f6e2b..b8e5cfb9dd 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; @@ -820,7 +823,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; } @@ -867,6 +870,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..d6921cc50c 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__)) @@ -338,8 +338,9 @@ typedef struct CheckasmPerf { uint64_t tsum = 0;\ int ti, tcount = 0;\ uint64_t t = 0; \ +const uint64_t truns = bench_runs;\ checkasm_set_signal_handler_state(1);\ -for (ti = 0; ti < BENCH_RUNS; ti++) {\ +for (ti = 0; ti < truns; ti++) {\ PERF_START(t);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ While working on the FFT asm with https://github.com/cyanreg/lavu_fft_test which has a built-in benchmark, I've found that exponentiation works best, as adding more and more digits at the end is prone to under/overshoot. For large functions, 1 << 16 is a good starting point, while for very small functions, 1 << 23 becomes more optimal. I suggest replacing --samples with --runs (or --bench-runs, but we're all lazy for that), and documenting it as "--runs=" and rejecting anything large enough to overflow. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3] checkasm: add sample argument to adjust during bench
On 21/05/2024 15:51, J. Dekker wrote: 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 by an exponent (--runs) has been added, allowing developers to increase the sample count for more reliable results. Signed-off-by: J. Dekker --- tests/checkasm/checkasm.c | 16 +++- tests/checkasm/checkasm.h | 7 --- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 31ca9f6e2b..669f2be9c1 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 = 1U << 10; + /* List of tests to invoke */ static const struct { const char *name; @@ -820,7 +823,7 @@ static void bench_uninit(void) static int usage(const char *path) { fprintf(stderr, -"Usage: %s [--bench] [--test=] [--verbose] [seed]\n", +"Usage: %s [--bench] [--runs=] [--test=] [--verbose] [seed]\n", path); return 1; } @@ -867,6 +870,17 @@ 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, "--runs=", 7)) { +l = strtoul(arg + 7, &end, 10); +if (*end == '\0') { +if (l > 30) { +fprintf(stderr, "checkasm: error: runs exponent must be within the range 0 <= 30\n"); +usage(argv[0]); +} +bench_runs = 1U << 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..e05053cbf6 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__)) @@ -336,10 +336,11 @@ typedef struct CheckasmPerf { av_unused const int sysfd = perf->sysfd;\ func_type *tfunc = func_new;\ uint64_t tsum = 0;\ -int ti, tcount = 0;\ +uint64_t ti, tcount = 0;\ uint64_t t = 0; \ +const uint64_t truns = bench_runs;\ checkasm_set_signal_handler_state(1);\ -for (ti = 0; ti < BENCH_RUNS; ti++) {\ +for (ti = 0; ti < truns; ti++) {\ PERF_START(t);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ Tested, works as intended LGTM, thanks 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] checkasm: print bench runs when benchmarking
Helps make sense of the possible noise in the results. --- tests/checkasm/checkasm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 669f2be9c1..b1c175b95d 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -892,6 +892,9 @@ int main(int argc, char *argv[]) fprintf(stderr, "checkasm: using random seed %u\n", seed); av_lfg_init(&checkasm_lfg, seed); +if (state.bench_pattern) +fprintf(stderr, "checkasm: bench runs %" PRIu64 " (1 << %i)\n", bench_runs, av_log2(bench_runs)); + check_cpu_flag(NULL, 0); for (i = 0; cpus[i].flag; i++) check_cpu_flag(cpus[i].name, cpus[i].flag); -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] checkasm: print bench runs when benchmarking
On 21/05/2024 17:07, J. Dekker wrote: Lynne via ffmpeg-devel writes: Helps make sense of the possible noise in the results. --- tests/checkasm/checkasm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 669f2be9c1..b1c175b95d 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -892,6 +892,9 @@ int main(int argc, char *argv[]) fprintf(stderr, "checkasm: using random seed %u\n", seed); av_lfg_init(&checkasm_lfg, seed); +if (state.bench_pattern) +fprintf(stderr, "checkasm: bench runs %" PRIu64 " (1 << %i)\n", bench_runs, av_log2(bench_runs)); + check_cpu_flag(NULL, 0); for (i = 0; cpus[i].flag; i++) check_cpu_flag(cpus[i].name, cpus[i].flag); LGTM. Thanks, pushed OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 21/05/2024 09:16, Marton Balint wrote: On Sun, 19 May 2024, Lynne via ffmpeg-devel wrote: On 19/05/2024 21:39, Marton Balint wrote: On Sun, 19 May 2024, Lynne via ffmpeg-devel wrote: This commit adds a decoder for the frequency-domain part of USAC. [...] +/* Finish later */ +static const enum AVChannel usac_ch_pos_to_av[64] = { + [0] = AV_CHAN_FRONT_LEFT, + [1] = AV_CHAN_FRONT_RIGHT, + [2] = AV_CHAN_FRONT_CENTER, + [3] = AV_CHAN_LOW_FREQUENCY, + [4] = AV_CHAN_BACK_LEFT, // unsure + [5] = AV_CHAN_BACK_RIGHT, // unsure + [6] = AV_CHAN_FRONT_LEFT_OF_CENTER, + [7] = AV_CHAN_FRONT_RIGHT_OF_CENTER, + [8] = 0, /* rear surround left is missing */ + [9] = 0, /* rear surround right is missing */ + [10] = AV_CHAN_BACK_CENTER, + [11] = AV_CHAN_SURROUND_DIRECT_LEFT, + [12] = AV_CHAN_SURROUND_DIRECT_RIGHT, + [13] = AV_CHAN_SIDE_LEFT, // fairly sure + [14] = AV_CHAN_SIDE_RIGHT, // fairly sure + [15] = AV_CHAN_WIDE_LEFT, // somewhat confident + [16] = AV_CHAN_WIDE_RIGHT, // somewhat confident + [17] = AV_CHAN_TOP_FRONT_LEFT, + [18] = AV_CHAN_TOP_FRONT_RIGHT, + [19] = AV_CHAN_TOP_FRONT_CENTER, + [20] = AV_CHAN_TOP_BACK_LEFT, + [21] = AV_CHAN_TOP_BACK_RIGHT, + [22] = AV_CHAN_TOP_BACK_CENTER, + [23] = AV_CHAN_TOP_SIDE_LEFT, + [24] = AV_CHAN_TOP_SIDE_RIGHT, + [25] = AV_CHAN_TOP_CENTER, + [26] = AV_CHAN_LOW_FREQUENCY, // actually LFE2 + [27] = AV_CHAN_BOTTOM_FRONT_LEFT, + [28] = AV_CHAN_BOTTOM_FRONT_RIGHT, + [29] = AV_CHAN_BOTTOM_FRONT_CENTER, + [30] = 0, /* top left surround is missing */ + [31] = 0, /* top right surround is missing */ +}; Some comment would be nice about the source of this table (which document, which table). It looks very similar to the ISO channel positons used in mov_chan. I think we follow this mapping in most cases: Left Surround is SIDE_LEFT Right Surround is SIDE_RIGHT Rear Surround Left is BACK_LEFT Rear Surround Right is BACK_RIGHT So in your table [4] and [5] should be SIDE, [8] and [9] should be BACK. [26] can be AV_CHAN_LOW_FREQUENCY_2, we do have that. Yes, Left/Right Surround and Left/Right Side Surround will be the same, but those are not present in commonly used layouts at the same time. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Source of the table is ISO/IEC 23003-3, Table 74 — bsOutputChannelPos: 0 L left front FL front left 1 R right front FR front right 2 C center front FC front centre 3 LFE low frequency enhancement LFE1 low frequency effects-1 4 Ls left surround LS left surround 5 Rs right surround RS right surround 6 Lc left front center FLc front left centre 7 Rc right front center FRc front right centre 8 Lsr rear surround left BL back left 9 Rsr rear surround right BR back right 10 Cs rear center BC back centre 11 Lsd left surround direct LSd left surround direct 12 Rsd right surround direct RSd right surround direct 13 Lss left side surround SL side left 14 Rss right side surround SR side right 15 Lw left wide front FLw front left wide 16 Rw right wide front FRw front right wide 17 Lv left front vertical height TpFL top front left 18 Rv right front vertical height TpFR top front right 19 Cv center front vertical height TpFC top front centre 20 Lvr left surround vertical height rear TpBL top back left 21 Rvr right surround vertical height rear TpBR top back right 22 Cvr center vertical height rear TpBC top back centre 23 Lvss left vertical height side surround TpSiL top side left 24 Rvss right vertical height side surround TpSiR top side right 25 Ts top center surround TpC top centre 26 LFE2 low frequency enhancement 2 LFE2 low frequency effects-2 27 Lb left front vertical bottom BtFL bottom front left 28 Rb right front vertical bottom BtFR bottom front right 29 Cb center front vertical bottom BtFC bottom front centre 30 Lvs left vertical height surround TpLS top left surround 31 Rvs right vertical height surround TpRS top right surround Third field is "Loudspeaker position", last field is "Loudspeaker position according to IEC 100/1706/CDV/IEC 62574 (TC100)", each prefixed with an abbreviation. I've added the source to the table comment in the code. I've also fixed the SIDE/BACK/LFE2 issue in my github repo I linked earlier. Thanks. Later in the code when you actually use this I can see that you are creating a native layout: + channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */ + if (!channel_config_idx) { + /* UsacChannelConfig() */ + uint8_t channel_pos[64]; + uint8_t nb_channels = get_escaped_value(gb, 5, 8, 16); /* numOutChannels */ + if (nb_channels &
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 21/05/2024 21:40, Marton Balint wrote: On Tue, 21 May 2024, Lynne via ffmpeg-devel wrote: On 21/05/2024 09:16, Marton Balint wrote: On Sun, 19 May 2024, Lynne via ffmpeg-devel wrote: On 19/05/2024 21:39, Marton Balint wrote: On Sun, 19 May 2024, Lynne via ffmpeg-devel wrote: This commit adds a decoder for the frequency-domain part of USAC. [...] +/* Finish later */ +static const enum AVChannel usac_ch_pos_to_av[64] = { + [0] = AV_CHAN_FRONT_LEFT, + [1] = AV_CHAN_FRONT_RIGHT, + [2] = AV_CHAN_FRONT_CENTER, + [3] = AV_CHAN_LOW_FREQUENCY, + [4] = AV_CHAN_BACK_LEFT, // unsure + [5] = AV_CHAN_BACK_RIGHT, // unsure + [6] = AV_CHAN_FRONT_LEFT_OF_CENTER, + [7] = AV_CHAN_FRONT_RIGHT_OF_CENTER, + [8] = 0, /* rear surround left is missing */ + [9] = 0, /* rear surround right is missing */ + [10] = AV_CHAN_BACK_CENTER, + [11] = AV_CHAN_SURROUND_DIRECT_LEFT, + [12] = AV_CHAN_SURROUND_DIRECT_RIGHT, + [13] = AV_CHAN_SIDE_LEFT, // fairly sure + [14] = AV_CHAN_SIDE_RIGHT, // fairly sure + [15] = AV_CHAN_WIDE_LEFT, // somewhat confident + [16] = AV_CHAN_WIDE_RIGHT, // somewhat confident + [17] = AV_CHAN_TOP_FRONT_LEFT, + [18] = AV_CHAN_TOP_FRONT_RIGHT, + [19] = AV_CHAN_TOP_FRONT_CENTER, + [20] = AV_CHAN_TOP_BACK_LEFT, + [21] = AV_CHAN_TOP_BACK_RIGHT, + [22] = AV_CHAN_TOP_BACK_CENTER, + [23] = AV_CHAN_TOP_SIDE_LEFT, + [24] = AV_CHAN_TOP_SIDE_RIGHT, + [25] = AV_CHAN_TOP_CENTER, + [26] = AV_CHAN_LOW_FREQUENCY, // actually LFE2 + [27] = AV_CHAN_BOTTOM_FRONT_LEFT, + [28] = AV_CHAN_BOTTOM_FRONT_RIGHT, + [29] = AV_CHAN_BOTTOM_FRONT_CENTER, + [30] = 0, /* top left surround is missing */ + [31] = 0, /* top right surround is missing */ +}; Some comment would be nice about the source of this table (which document, which table). It looks very similar to the ISO channel positons used in mov_chan. I think we follow this mapping in most cases: Left Surround is SIDE_LEFT Right Surround is SIDE_RIGHT Rear Surround Left is BACK_LEFT Rear Surround Right is BACK_RIGHT So in your table [4] and [5] should be SIDE, [8] and [9] should be BACK. [26] can be AV_CHAN_LOW_FREQUENCY_2, we do have that. Yes, Left/Right Surround and Left/Right Side Surround will be the same, but those are not present in commonly used layouts at the same time. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Source of the table is ISO/IEC 23003-3, Table 74 — bsOutputChannelPos: 0 L left front FL front left 1 R right front FR front right 2 C center front FC front centre 3 LFE low frequency enhancement LFE1 low frequency effects-1 4 Ls left surround LS left surround 5 Rs right surround RS right surround 6 Lc left front center FLc front left centre 7 Rc right front center FRc front right centre 8 Lsr rear surround left BL back left 9 Rsr rear surround right BR back right 10 Cs rear center BC back centre 11 Lsd left surround direct LSd left surround direct 12 Rsd right surround direct RSd right surround direct 13 Lss left side surround SL side left 14 Rss right side surround SR side right 15 Lw left wide front FLw front left wide 16 Rw right wide front FRw front right wide 17 Lv left front vertical height TpFL top front left 18 Rv right front vertical height TpFR top front right 19 Cv center front vertical height TpFC top front centre 20 Lvr left surround vertical height rear TpBL top back left 21 Rvr right surround vertical height rear TpBR top back right 22 Cvr center vertical height rear TpBC top back centre 23 Lvss left vertical height side surround TpSiL top side left 24 Rvss right vertical height side surround TpSiR top side right 25 Ts top center surround TpC top centre 26 LFE2 low frequency enhancement 2 LFE2 low frequency effects-2 27 Lb left front vertical bottom BtFL bottom front left 28 Rb right front vertical bottom BtFR bottom front right 29 Cb center front vertical bottom BtFC bottom front centre 30 Lvs left vertical height surround TpLS top left surround 31 Rvs right vertical height surround TpRS top right surround Third field is "Loudspeaker position", last field is "Loudspeaker position according to IEC 100/1706/CDV/IEC 62574 (TC100)", each prefixed with an abbreviation. I've added the source to the table comment in the code. I've also fixed the SIDE/BACK/LFE2 issue in my github repo I linked earlier. Thanks. Later in the code when you actually use this I can see that you are creating a native layout: + channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */ + if (!channel_conf
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 21/05/2024 23:33, Hendrik Leppkes wrote: On Tue, May 21, 2024 at 9:52 PM Lynne via ffmpeg-devel wrote: It should be the case here, we shouldn't need reordering as NATIVE just lets you specify what order the elements appear in the bitstream. NATIVE means "the FFmpeg native ordering", not "bitstream order". CUSTOM lets you specify an arbitrary order but requires metadata to that effect, but it makes it particularly hard to map to any standard when playing or transcoding, so some efforts to try to unify it into a NATIVE format is always appreciated if possible. Right, I forgot about that, thanks. Amended in my git repo to use Marton's code. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavc/vp9: set update_map to 0 when segmentation.enabled is 0
On 22/05/2024 18:17, Philip Langdale via ffmpeg-devel wrote: On Wed, 22 May 2024 11:10:31 -0400 "Ronald S. Bultje" wrote: Hi, On Wed, May 22, 2024 at 10:36 AM Hendrik Leppkes wrote: On Thu, Feb 29, 2024 at 7:19 AM llyyr wrote: segmentation.update_map is never reset to 0 on a new frame, and retains the value from the previous frame. This bugs out a bunch of hwaccel drivers when segmentation.enabled is 0 but update_map isn't because they don't ignore values behind switches. We also do this for vp8* so this commit is just mirroring the vp8 logic. This fixes an issue with certain samples** that causes blocky artifacts with vaapi and d3d11va (as far as known hwaccel drivers go). Mesa worked around*** this by ignoring this field if segmentation.enabled is 0, but d3d11va still doesn't work. * https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavcodec/vp8.c#l811 ** https://github.com/mpv-player/mpv/issues/13533 *** https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27816 Signed-off-by: llyyr --- libavcodec/vp9.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 855936cdc1c7..4a628625131e 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -717,6 +717,8 @@ static int decode_frame_header(AVCodecContext *avctx, s->s.h.segmentation.feat[i].skip_enabled = get_bits1(&s->gb); } } +} else { +s->s.h.segmentation.update_map = 0; } // set qmul[] based on Y/UV, AC/DC and segmentation Q idx deltas base-commit: d263fce2b209e86a5a1e8f1b6aa33430ecc2c187 -- Change LGTM. I was debugging the same issue today, and found the same problem with some hwaccels not properly ignoring update_map when segmentation is disabled. Will apply soon if there are no further comments. Is fine, please apply. Another LGTM. We've been seeing this reported on the mpv side as well. --phil ___ 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". Can't this get fixed by hwaccel code rather than globally? I'd hate to apply fixes with no information in shared code. This can get removed with no information about what relies on it. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 8/8] aacdec: add a decoder for AAC USAC (xHE-AAC)
On 22/05/2024 22:15, Marton Balint wrote: On Wed, 22 May 2024, Lynne via ffmpeg-devel wrote: On 21/05/2024 23:33, Hendrik Leppkes wrote: On Tue, May 21, 2024 at 9:52 PM Lynne via ffmpeg-devel wrote: It should be the case here, we shouldn't need reordering as NATIVE just lets you specify what order the elements appear in the bitstream. NATIVE means "the FFmpeg native ordering", not "bitstream order". CUSTOM lets you specify an arbitrary order but requires metadata to that effect, but it makes it particularly hard to map to any standard when playing or transcoding, so some efforts to try to unify it into a NATIVE format is always appreciated if possible. Right, I forgot about that, thanks. Amended in my git repo to use Marton's code. ret = av_channel_layout_custom_init(&ac->oc[1].ch_layout, nb_channels); if (ret < 0) return ret; for (int i = 0; i < nb_channels; i++) { AVChannelCustom *cm = &ac->oc[1].ch_layout.u.map[i]; cm->id = usac_ch_pos_to_av[get_bits(gb, 5)]; /* bsOutputChannelPos */ if (cm->id) cm->id = AV_CHAN_UNKNOWN; if (cm->id == AV_CHAN_NONE) cm->id = AV_CHAN_UNKNOWN; } ret = av_channel_layout_retype(&ac->oc[1].ch_layout, AV_CHANNEL_ORDER_NATIVE, AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL); You can simply pass 0 instead of AV_CHANNEL_ORDER_NATIVE as the order parameter, because AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL automatically uses the canonical order and ignores the order parameter. if (ret < 0) return ret; av_channel_layout_copy(&avctx->ch_layout, &ac->oc[1].ch_layout); Missing error check. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Fixed both, thanks. I'll keep AV_CHANNEL_ORDER_NATIVE as-is because its just more readable. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode: introduce a base layer for vaapi encode
On 20/05/2024 16:52, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Since VAAPI and future D3D12VA implementation may share some common parameters, a base layer encode context is introduced as vaapi context's base. Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.h | 56 + libavcodec/vaapi_encode.h | 39 +- 2 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 libavcodec/hw_base_encode.h diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h new file mode 100644 index 00..1996179456 --- /dev/null +++ b/libavcodec/hw_base_encode.h @@ -0,0 +1,56 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_HW_BASE_ENCODE_H +#define AVCODEC_HW_BASE_ENCODE_H + +#define MAX_DPB_SIZE 16 +#define MAX_PICTURE_REFERENCES 2 +#define MAX_REORDER_DELAY 16 +#define MAX_ASYNC_DEPTH 64 +#define MAX_REFERENCE_LIST_NUM 2 + +enum { +PICTURE_TYPE_IDR = 0, +PICTURE_TYPE_I = 1, +PICTURE_TYPE_P = 2, +PICTURE_TYPE_B = 3, +}; + +enum { +// Codec supports controlling the subdivision of pictures into slices. +FLAG_SLICE_CONTROL = 1 << 0, +// Codec only supports constant quality (no rate control). +FLAG_CONSTANT_QUALITY_ONLY = 1 << 1, +// Codec is intra-only. +FLAG_INTRA_ONLY= 1 << 2, +// Codec supports B-pictures. +FLAG_B_PICTURES= 1 << 3, +// Codec supports referencing B-pictures. +FLAG_B_PICTURE_REFERENCES = 1 << 4, +// Codec supports non-IDR key pictures (that is, key pictures do +// not necessarily empty the DPB). +FLAG_NON_IDR_KEY_PICTURES = 1 << 5, +}; + +typedef struct HWBaseEncodeContext { +const AVClass *class; +} HWBaseEncodeContext; + +#endif /* AVCODEC_HW_BASE_ENCODE_H */ + diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 0eed9691ca..f5c9be8973 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -33,34 +33,27 @@ #include "avcodec.h" #include "hwconfig.h" +#include "hw_base_encode.h" struct VAAPIEncodeType; struct VAAPIEncodePicture; +// Codec output packet without timestamp delay, which means the +// output packet has same PTS and DTS. +#define FLAG_TIMESTAMP_NO_DELAY 1 << 6 + enum { MAX_CONFIG_ATTRIBUTES = 4, MAX_GLOBAL_PARAMS = 4, -MAX_DPB_SIZE = 16, -MAX_PICTURE_REFERENCES = 2, -MAX_REORDER_DELAY = 16, MAX_PARAM_BUFFER_SIZE = 1024, // A.4.1: table A.6 allows at most 22 tile rows for any level. MAX_TILE_ROWS = 22, // A.4.1: table A.6 allows at most 20 tile columns for any level. MAX_TILE_COLS = 20, -MAX_ASYNC_DEPTH= 64, -MAX_REFERENCE_LIST_NUM = 2, }; extern const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]; -enum { -PICTURE_TYPE_IDR = 0, -PICTURE_TYPE_I = 1, -PICTURE_TYPE_P = 2, -PICTURE_TYPE_B = 3, -}; - typedef struct VAAPIEncodeSlice { int index; int row_start; @@ -193,7 +186,8 @@ typedef struct VAAPIEncodeRCMode { } VAAPIEncodeRCMode; typedef struct VAAPIEncodeContext { -const AVClass *class; +// Base context. +HWBaseEncodeContext base; // Codec-specific hooks. const struct VAAPIEncodeType *codec; @@ -397,25 +391,6 @@ typedef struct VAAPIEncodeContext { AVPacket*tail_pkt; } VAAPIEncodeContext; -enum { -// Codec supports controlling the subdivision of pictures into slices. -FLAG_SLICE_CONTROL = 1 << 0, -// Codec only supports constant quality (no rate control). -FLAG_CONSTANT_QUALITY_ONLY = 1 << 1, -// Codec is intra-only. -FLAG_INTRA_ONLY= 1 << 2, -// Codec supports B-pictures. -FLAG_B_PICTURES= 1 << 3, -// Codec supports referencing B-pictures. -FLAG_B_PICTURE_REFERENCES = 1 << 4, -// Codec supports non-IDR key pictures (that is, key pictures do -// not necessarily empty the DPB). -FLAG_NON_IDR_KEY_PICTURES = 1 << 5, -// Codec output packet without timestamp delay, which means the -// output packet has same PTS and DTS. -FLAG_TIMESTAMP_NO_DEL
Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode: introduce a base layer for vaapi encode
On 24/05/2024 17:39, Wu, Tong1 wrote: -Original Message- From: ffmpeg-devel On Behalf Of Lynne via ffmpeg-devel Sent: Friday, May 24, 2024 12:11 AM To: ffmpeg-devel@ffmpeg.org Cc: Lynne Subject: Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode: introduce a base layer for vaapi encode On 20/05/2024 16:52, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Since VAAPI and future D3D12VA implementation may share some common parameters, a base layer encode context is introduced as vaapi context's base. Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.h | 56 + libavcodec/vaapi_encode.h | 39 +- 2 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 libavcodec/hw_base_encode.h diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h new file mode 100644 index 00..1996179456 --- /dev/null +++ b/libavcodec/hw_base_encode.h @@ -0,0 +1,56 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_HW_BASE_ENCODE_H +#define AVCODEC_HW_BASE_ENCODE_H + +#define MAX_DPB_SIZE 16 +#define MAX_PICTURE_REFERENCES 2 +#define MAX_REORDER_DELAY 16 +#define MAX_ASYNC_DEPTH 64 +#define MAX_REFERENCE_LIST_NUM 2 + +enum { +PICTURE_TYPE_IDR = 0, +PICTURE_TYPE_I = 1, +PICTURE_TYPE_P = 2, +PICTURE_TYPE_B = 3, +}; + +enum { +// Codec supports controlling the subdivision of pictures into slices. +FLAG_SLICE_CONTROL = 1 << 0, +// Codec only supports constant quality (no rate control). +FLAG_CONSTANT_QUALITY_ONLY = 1 << 1, +// Codec is intra-only. +FLAG_INTRA_ONLY= 1 << 2, +// Codec supports B-pictures. +FLAG_B_PICTURES= 1 << 3, +// Codec supports referencing B-pictures. +FLAG_B_PICTURE_REFERENCES = 1 << 4, +// Codec supports non-IDR key pictures (that is, key pictures do +// not necessarily empty the DPB). +FLAG_NON_IDR_KEY_PICTURES = 1 << 5, +}; + +typedef struct HWBaseEncodeContext { +const AVClass *class; +} HWBaseEncodeContext; + +#endif /* AVCODEC_HW_BASE_ENCODE_H */ + diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 0eed9691ca..f5c9be8973 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -33,34 +33,27 @@ #include "avcodec.h" #include "hwconfig.h" +#include "hw_base_encode.h" struct VAAPIEncodeType; struct VAAPIEncodePicture; +// Codec output packet without timestamp delay, which means the +// output packet has same PTS and DTS. +#define FLAG_TIMESTAMP_NO_DELAY 1 << 6 + enum { MAX_CONFIG_ATTRIBUTES = 4, MAX_GLOBAL_PARAMS = 4, -MAX_DPB_SIZE = 16, -MAX_PICTURE_REFERENCES = 2, -MAX_REORDER_DELAY = 16, MAX_PARAM_BUFFER_SIZE = 1024, // A.4.1: table A.6 allows at most 22 tile rows for any level. MAX_TILE_ROWS = 22, // A.4.1: table A.6 allows at most 20 tile columns for any level. MAX_TILE_COLS = 20, -MAX_ASYNC_DEPTH= 64, -MAX_REFERENCE_LIST_NUM = 2, }; extern const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]; -enum { -PICTURE_TYPE_IDR = 0, -PICTURE_TYPE_I = 1, -PICTURE_TYPE_P = 2, -PICTURE_TYPE_B = 3, -}; - typedef struct VAAPIEncodeSlice { int index; int row_start; @@ -193,7 +186,8 @@ typedef struct VAAPIEncodeRCMode { } VAAPIEncodeRCMode; typedef struct VAAPIEncodeContext { -const AVClass *class; +// Base context. +HWBaseEncodeContext base; // Codec-specific hooks. const struct VAAPIEncodeType *codec; @@ -397,25 +391,6 @@ typedef struct VAAPIEncodeContext { AVPacket*tail_pkt; } VAAPIEncodeContext; -enum { -// Codec supports controlling the subdivision of pictures into slices. -FLAG_SLICE_CONTROL = 1 << 0, -// Codec only supports constant quality (no rate control). -FLAG_CONSTANT_QUALITY_ONLY = 1 << 1, -// Codec is intra-only. -FLAG_INTRA_ONLY= 1 << 2, -// Codec supports B-pi
[FFmpeg-devel] [PATCH v3 02/10] 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/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 3 files changed, 83 insertions(+), 117 deletions(-) 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; case INTENSITY_BT: /* fallthrough */ case INTENSITY_BT2: -for (; i < run_end; i++, idx++) { -offset[2] += get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - SCALE_DIFF_ZERO; -clipped_offset = av_clip(offset[2], -155, 100); -if (offset[2] != clipped_offset) { -avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset);
[FFmpeg-devel] [PATCH v3 00/10] aacdec: add a native xHE-AAC decoder
This commit adds a decoder for the frequency-domain part of USAC. SBR is as of now not yet supported, will be added with a future patch. A known issue is that preroll frames (usually present quite often within the file, as xHE-AAC has real keyframes and I-frames) can cause artifacts. Lynne (10): channel_layout: add new channel positions supported by xHE-AAC 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) fate: add tests for xHE-AAC libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 371 +++--- libavcodec/aac/aacdec.h | 219 +++- libavcodec/aac/aacdec_ac.c | 208 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 | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1592 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 560 + libavcodec/aactab.h | 22 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + libavutil/channel_layout.h |4 + tests/fate/aac.mak |8 + 19 files changed, 3262 insertions(+), 235 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 v3 03/10] 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 v3 04/10] 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 bea0578e92..499bd8eefc 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 v3 01/10] channel_layout: add new channel positions supported by xHE-AAC
apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.h | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 8a078d1601..4e19bbbd9e 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, +AV_CHAN_SURROUND_LEFT, +AV_CHAN_SURROUND_RIGHT, +AV_CHAN_TOP_SURROUND_LEFT, +AV_CHAN_TOP_SURROUND_RIGHT, /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, -- 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 v3 07/10] 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, +
[FFmpeg-devel] [PATCH v3 05/10] 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 499bd8eefc..8d1eb74066 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 v3 06/10] 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 v3 08/10] 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 v3 09/10] 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) - Stereo (complex prediction) What's left: - Speech coding Known issues: - Desync with certain sequences - Preroll crossover missing (shouldn't matter, bitrate adaptation only) --- libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 188 +-- libavcodec/aac/aacdec.h | 187 +++ libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1592 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 42 + libavcodec/aactab.h | 10 + 13 files changed, 2494 insertions(+), 76 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 c3e525d373..70b1dca274 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 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..2b8322fc68 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 re
[FFmpeg-devel] [PATCH v3 10/10] fate: add tests for xHE-AAC
Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. FATE files: https://files.lynne.ee/xhe_refs/ --- tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v11 07/14] avcodec/vaapi_encode: extract the init and close function to base layer
On 25/05/2024 12:30, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Related parameters such as device context, frame context are also moved to base layer. Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.c | 49 ++ libavcodec/hw_base_encode.h | 17 +++ libavcodec/vaapi_encode.c | 90 +++-- libavcodec/vaapi_encode.h | 10 libavcodec/vaapi_encode_av1.c | 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 6 ++- 8 files changed, 102 insertions(+), 76 deletions(-) diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 16afaa37be..c4789380b6 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -592,3 +592,52 @@ end: return 0; } + +int ff_hw_base_encode_init(AVCodecContext *avctx) +{ +FFHWBaseEncodeContext *ctx = avctx->priv_data; This is the issue I was talking about, this requires that FFHWBaseEncodeContext is always the main context. Could you change it so everything takes FFHWBaseEncodeContext as an argument, rather than AVCodecContext (apart from where the function absolutely must read some data from it)? OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v11 07/14] avcodec/vaapi_encode: extract the init and close function to base layer
On 25/05/2024 16:18, Sean McGovern wrote: Hi, On Sat, May 25, 2024, 09:07 Lynne via ffmpeg-devel wrote: On 25/05/2024 12:30, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Related parameters such as device context, frame context are also moved to base layer. Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.c | 49 ++ libavcodec/hw_base_encode.h | 17 +++ libavcodec/vaapi_encode.c | 90 +++-- libavcodec/vaapi_encode.h | 10 libavcodec/vaapi_encode_av1.c | 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 6 ++- 8 files changed, 102 insertions(+), 76 deletions(-) diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 16afaa37be..c4789380b6 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -592,3 +592,52 @@ end: return 0; } + +int ff_hw_base_encode_init(AVCodecContext *avctx) +{ +FFHWBaseEncodeContext *ctx = avctx->priv_data; This is the issue I was talking about, this requires that FFHWBaseEncodeContext is always the main context. Could you change it so everything takes FFHWBaseEncodeContext as an argument, rather than AVCodecContext (apart from where the function absolutely must read some data from it)? Might this suggestion involve having to do some ugly down-casting? Not at all. Instead of having this context as the main context, just make each encoder have its own context, where this structure is the only element. Vulkan requires extra state, such as an execution context, function pointers from the loader, memory the encoder needs, which, rather than adding to this structure, would be better off being in its own context. 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] lpc: rewrite lpc_compute_autocorr in external asm
The inline asm function had issues running under checkasm. So I came to finish what I started, and wrote the last part of LPC computation in assembly. autocorr_10_c: 135525.8 autocorr_10_sse2: 50729.8 autocorr_10_fma3: 19007.8 autocorr_30_c: 390100.8 autocorr_30_sse2: 142478.8 autocorr_30_fma3: 50559.8 autocorr_32_c: 407058.3 autocorr_32_sse2: 151633.3 autocorr_32_fma3: 50517.3 --- libavcodec/x86/lpc.asm| 91 +++ libavcodec/x86/lpc_init.c | 87 - 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index a585c17ef5..790841b7f4 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -32,6 +32,8 @@ dec_tab_sse2: times 2 dq -2.0 dec_tab_scalar: times 2 dq -1.0 seq_tab_sse2: dq 1.0, 0.0 +autoc_init_tab: times 4 dq 1.0 + SECTION .text %macro APPLY_WELCH_FN 0 @@ -261,3 +263,92 @@ APPLY_WELCH_FN INIT_YMM avx2 APPLY_WELCH_FN %endif + +%macro COMPUTE_AUTOCORR_FN 0 +cglobal lpc_compute_autocorr, 4, 7, 8, data, len, lag, autoc, lag_p, data_l, len_p + +shl lagd, 3 +shl lenq, 3 +xor lag_pq, lag_pq + +.lag_l: +movaps m8, [autoc_init_tab] + +mov len_pq, lag_pq + +lea data_lq, [lag_pq + mmsize - 8] +neg data_lq ; -j - mmsize +add data_lq, dataq ; data[-j - mmsize] +.len_l: +; We waste the upper value here on SSE2, +; but we use it on AVX. +movupd xm0, [dataq + len_pq]; data[i] +movupd m1, [data_lq + len_pq] ; data[i - j] + +%if cpuflag(avx) +vbroadcastsd m0, xm0 +vperm2f128 m1, m1, m1, 0x01 +%endif + +shufpd m0, m0, m0, 1100b +shufpd m1, m1, m1, 0101b + +%if cpuflag(fma3) +fmaddpd m8, m0, m1, m8 ; sum += data[i]*data[i-j] +%else +mulpd m0, m1 +addpd m8, m0; sum += data[i]*data[i-j] +%endif + +add len_pq, 8 +cmp len_pq, lenq +jl .len_l + +movups [autocq + lag_pq], m8; autoc[j] = sum +add lag_pq, mmsize +cmp lag_pq, lagq +jl .lag_l + +; The tail computation is guaranteed never to happen +; as long as we're doing multiples of 4, rather than 2. +; It is trivial to convert this to avx if ever needed. +%if !cpuflag(avx) +jg .end +; If lag_p == lag fallthrough + +.tail: +movaps xm2, [autoc_init_tab] + +mov len_pq, lag_pq +sub len_pq, mmsize + +lea data_lq, [lag_pq] +neg data_lq ; -j +add data_lq, dataq ; data[-j] + +.tail_l: +movupd xm0, [dataq + len_pq] +movupd xm1, [data_lq + len_pq] + +mulpd xm0, xm1 +addpd xm2, xm0 ; sum += data[i]*data[i-j] + +add len_pq, mmsize +cmp len_pq, lenq +jl .tail_l + +shufpd xm1, xm2, xm2, 01b +addpd xm2, xm1 + +movhpd [autocq + lag_pq], xm2 +%endif + +.end: +RET + +%endmacro + +INIT_XMM sse2 +COMPUTE_AUTOCORR_FN +INIT_YMM fma3 +COMPUTE_AUTOCORR_FN diff --git a/libavcodec/x86/lpc_init.c b/libavcodec/x86/lpc_init.c index f2fca53799..96469fae40 100644 --- a/libavcodec/x86/lpc_init.c +++ b/libavcodec/x86/lpc_init.c @@ -28,89 +28,20 @@ void ff_lpc_apply_welch_window_sse2(const int32_t *data, ptrdiff_t len, double *w_data); void ff_lpc_apply_welch_window_avx2(const int32_t *data, ptrdiff_t len, double *w_data); - -DECLARE_ASM_CONST(16, double, pd_1)[2] = { 1.0, 1.0 }; - -#if HAVE_SSE2_INLINE - -static void lpc_compute_autocorr_sse2(const double *data, ptrdiff_t len, int lag, - double *autoc) -{ -int j; - -if((x86_reg)data & 15) -data++; - -for(j=0; jlpc_compute_autocorr = lpc_compute_autocorr_sse2; -#endif +if (EXTERNAL_SSE2(cpu_flags)) +c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2; + +if (EXTERNAL_FMA3(cpu_flags)) +c->lpc_compute_autocorr = ff_lpc_compute_autocorr_fma3; if (EXTERNAL_SSE2(cpu_flags)) c->lpc_apply_welch_window = ff_lpc_apply_welch_window_sse2; -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lpc: rewrite lpc_compute_autocorr in external asm
On 26/05/2024 00:31, James Almer wrote: On 5/25/2024 5:57 PM, Lynne via ffmpeg-devel wrote: The inline asm function had issues running under checkasm. So I came to finish what I started, and wrote the last part of LPC computation in assembly. autocorr_10_c: 135525.8 autocorr_10_sse2: 50729.8 autocorr_10_fma3: 19007.8 autocorr_30_c: 390100.8 autocorr_30_sse2: 142478.8 autocorr_30_fma3: 50559.8 autocorr_32_c: 407058.3 autocorr_32_sse2: 151633.3 autocorr_32_fma3: 50517.3 --- libavcodec/x86/lpc.asm | 91 +++ libavcodec/x86/lpc_init.c | 87 - 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index a585c17ef5..790841b7f4 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -32,6 +32,8 @@ dec_tab_sse2: times 2 dq -2.0 dec_tab_scalar: times 2 dq -1.0 seq_tab_sse2: dq 1.0, 0.0 +autoc_init_tab: times 4 dq 1.0 + SECTION .text %macro APPLY_WELCH_FN 0 @@ -261,3 +263,92 @@ APPLY_WELCH_FN INIT_YMM avx2 APPLY_WELCH_FN %endif + +%macro COMPUTE_AUTOCORR_FN 0 +cglobal lpc_compute_autocorr, 4, 7, 8, data, len, lag, autoc, lag_p, data_l, len_p Already mentioned, but it should be 3 not 8. Already done, as said on IRC not 10 minutes after I submitted it. + + shl lagd, 3 + shl lenq, 3 + xor lag_pq, lag_pq + +.lag_l: + movaps m8, [autoc_init_tab] m2 + + mov len_pq, lag_pq + + lea data_lq, [lag_pq + mmsize - 8] + neg data_lq ; -j - mmsize + add data_lq, dataq ; data[-j - mmsize] +.len_l: + ; We waste the upper value here on SSE2, + ; but we use it on AVX. + movupd xm0, [dataq + len_pq] ; data[i] movsd Fixed. + movupd m1, [data_lq + len_pq] ; data[i - j] + +%if cpuflag(avx) %if mmsize == 32 here and everywhere else. Done. + vbroadcastsd m0, xm0 This is AVX2. AVX only has memory input argument. So use that and save the movsd from above for the FMA3 version. + vperm2f128 m1, m1, m1, 0x01 Aren't you loading 16 extra bytes for no reason if you're just going to use the upper 16 bytes from the load above? Lane swapped, like you mentioned. +%endif + + shufpd m0, m0, m0, 1100b The last argument has two bits, not four. What you're doing here is a splat/broadcast, so you don't need it for FMA3. + shufpd m1, m1, m1, 0101b The upper two bits of imm8 are ignored. Intentional. Not ignored on FMA3. + +%if cpuflag(fma3) + fmaddpd m8, m0, m1, m8 ; sum += data[i]*data[i-j] +%else + mulpd m0, m1 + addpd m8, m0 ; sum += data[i]*data[i-j] +%endif + + add len_pq, 8 + cmp len_pq, lenq + jl .len_l + + movups [autocq + lag_pq], m8 ; autoc[j] = sum + add lag_pq, mmsize + cmp lag_pq, lagq + jl .lag_l + + ; The tail computation is guaranteed never to happen + ; as long as we're doing multiples of 4, rather than 2. + ; It is trivial to convert this to avx if ever needed. +%if !cpuflag(avx) This doesn't seem to be tested as is. Maybe the checkasm should try other lag values? That's for the checkasm patch. You can trigger this check with fate-alac-16-lpc-orders as-is. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lpc: rewrite lpc_compute_autocorr in external asm
On 26/05/2024 00:45, James Almer wrote: On 5/25/2024 7:31 PM, James Almer wrote: On 5/25/2024 5:57 PM, Lynne via ffmpeg-devel wrote: The inline asm function had issues running under checkasm. So I came to finish what I started, and wrote the last part of LPC computation in assembly. autocorr_10_c: 135525.8 autocorr_10_sse2: 50729.8 autocorr_10_fma3: 19007.8 autocorr_30_c: 390100.8 autocorr_30_sse2: 142478.8 autocorr_30_fma3: 50559.8 autocorr_32_c: 407058.3 autocorr_32_sse2: 151633.3 autocorr_32_fma3: 50517.3 --- libavcodec/x86/lpc.asm | 91 +++ libavcodec/x86/lpc_init.c | 87 - 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index a585c17ef5..790841b7f4 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -32,6 +32,8 @@ dec_tab_sse2: times 2 dq -2.0 dec_tab_scalar: times 2 dq -1.0 seq_tab_sse2: dq 1.0, 0.0 +autoc_init_tab: times 4 dq 1.0 + SECTION .text %macro APPLY_WELCH_FN 0 @@ -261,3 +263,92 @@ APPLY_WELCH_FN INIT_YMM avx2 APPLY_WELCH_FN %endif + +%macro COMPUTE_AUTOCORR_FN 0 +cglobal lpc_compute_autocorr, 4, 7, 8, data, len, lag, autoc, lag_p, data_l, len_p Already mentioned, but it should be 3 not 8. + + shl lagd, 3 + shl lenq, 3 + xor lag_pq, lag_pq + +.lag_l: + movaps m8, [autoc_init_tab] m2 + + mov len_pq, lag_pq + + lea data_lq, [lag_pq + mmsize - 8] + neg data_lq ; -j - mmsize + add data_lq, dataq ; data[-j - mmsize] +.len_l: + ; We waste the upper value here on SSE2, + ; but we use it on AVX. + movupd xm0, [dataq + len_pq] ; data[i] movsd + movupd m1, [data_lq + len_pq] ; data[i - j] + +%if cpuflag(avx) %if mmsize == 32 here and everywhere else. + vbroadcastsd m0, xm0 This is AVX2. AVX only has memory input argument. So use that and save the movsd from above for the FMA3 version. + vperm2f128 m1, m1, m1, 0x01 Aren't you loading 16 extra bytes for no reason if you're just going to use the upper 16 bytes from the load above? Nevermind, this is swapping lanes. That aside, these versions are barely better and sometimes worse in all my tests on win64 with GCC with certain seeds. For example, seed 4022958484 gives me: autocorr_10_c: 21345.6 autocorr_10_sse2: 16434.6 autocorr_10_fma3: 24154.6 autocorr_30_c: 59239.1 autocorr_30_sse2: 46114.6 autocorr_30_fma3: 64147.1 autocorr_32_c: 63022.1 autocorr_32_sse2: 50040.1 autocorr_32_fma3: 66594.1 But seed 2236774811 gives me: autocorr_10_c: 37135.3 autocorr_10_sse2: 26492.3 autocorr_10_fma3: 32943.3 autocorr_30_c: 102266.8 autocorr_30_sse2: 72933.3 autocorr_30_fma3: 85808.3 autocorr_32_c: 106537.8 autocorr_32_sse2: 77623.3 autocorr_32_fma3: 85844.3 But if i force len to always be 4999 instead of its value varying depending on seed, i consistently get things like: autocorr_10_c: 40447.3 autocorr_10_sse2: 39526.8 autocorr_10_fma3: 42955.3 autocorr_30_c: 111362.3 autocorr_30_sse2: 111408.3 autocorr_30_fma3: 116781.8 autocorr_32_c: 122388.3 autocorr_32_sse2: 119125.3 autocorr_32_fma3: 114239.3 It would help if someone else could confirm this, but overall i don't see any worthwhile gain here. The old inline version, for those seeds where it worked, was somewhat faster. The metrics given are on Zen 3, with Clang with compiler optimizations disabled. We do not rely on compiler optimizations, and have plenty of assembly which turns out to be slower than modern compilers autovectorizing (even though we disable tree vectorization on GCC, that does not apply to simple loops like this one). On the other hand, we also support ancient compilers, and compilers which have no understanding of vectorization at all. To illustrate how different results can look on different arches and compilers, and even platforms (you mentioned you tested only on win64): Zen 3, gcc-9, O2: autocorr_10_c: 48796.8 autocorr_10_sse2: 39571.8 autocorr_10_fma3: 30272.8 autocorr_30_c: 138499.3 autocorr_30_sse2: 114091.3 autocorr_30_fma3: 82114.3 autocorr_32_c: 146466.8 autocorr_32_sse2: 118400.8 autocorr_32_fma3: 80473.8 Zen 3, gcc-14, O2: autocorr_10_c: 44981.3 autocorr_10_sse2: 36481.3 autocorr_10_fma3: 18418.8 autocorr_30_c: 129462.8 autocorr_30_sse2: 104175.3 autocorr_30_fma3: 48670.3 autocorr_32_c: 135625.3 autocorr_32_sse2: 109079.8 autocorr_32_fma3: 48670.3 Zen 3, clang-18, O2: autocorr_10_c: 51872.6 autocorr_10_sse2: 48311.1 autocorr_10_fma3: 30070.1 autocorr_30_c: 145899.6 autocorr_30_sse2: 135793.1 autocorr_30_fma3: 79922.6 autocorr_32_c: 160443.1 autocorr_32_sse2: 147591.1 autocorr_32_fma3: 80075.6 Skylake, gcc-14, O2: autocorr_10_c: 149251.0 autocorr_10_sse2: 133769.5 autocorr_10_fma3: 72886.0 autocorr_30_c: 396145.0 autocorr_30_sse2: 376618.5 autocorr_30_fma3: 194116.5 autocorr_32_c: 413219.0 autocorr_32_sse2: 400867.5 autocorr_32_fma3: 194117.5 Skylak
[FFmpeg-devel] [PATCH v2] lpc: rewrite lpc_compute_autocorr in external asm
The inline asm function had issues running under checkasm. So I came to finish what I started, and wrote the last part of LPC computation in assembly. --- libavcodec/x86/lpc.asm| 91 +++ libavcodec/x86/lpc_init.c | 87 - 2 files changed, 100 insertions(+), 78 deletions(-) diff --git a/libavcodec/x86/lpc.asm b/libavcodec/x86/lpc.asm index a585c17ef5..9c359ae480 100644 --- a/libavcodec/x86/lpc.asm +++ b/libavcodec/x86/lpc.asm @@ -261,3 +261,94 @@ APPLY_WELCH_FN INIT_YMM avx2 APPLY_WELCH_FN %endif + +%macro COMPUTE_AUTOCORR_FN 0 +cglobal lpc_compute_autocorr, 4, 7, 3, data, len, lag, autoc, lag_p, data_l, len_p +shl lagd, 3 +shl lenq, 3 +xor lag_pq, lag_pq + +.lag_l: +movaps m2, [one_tab] + +mov len_pq, lag_pq + +lea data_lq, [lag_pq + mmsize - 8] +neg data_lq ; -j - mmsize +add data_lq, dataq ; data[-j - mmsize] +.len_l: + +%if mmsize == 32 +vbroadcastsd m0, [dataq + len_pq] +vpermpd m1, [data_lq + len_pq], q0123 +%else +movupd m1, [data_lq + len_pq] ; data[i - j] +movsd xm0, [dataq + len_pq] ; data[i] +shufpd m1, m1, m1, 01b +%endif + +shufpd m0, m0, m0, 1100b + +; fmadd actually hurts performance in this case due to +; the earlier loads + shuffles +mulpd m0, m1 +addpd m2, m0; sum += data[i]*data[i-j] + +add len_pq, 8 +cmp len_pq, lenq +jl .len_l + +movupd [autocq + lag_pq], m2; autoc[j] = sum +add lag_pq, mmsize +cmp lag_pq, lagq +jl .lag_l + +; The tail computation is guaranteed never to happen +; as long as we're doing multiples of 4, rather than 2. +%if mmsize != 32 +jg .end +; If lag_p == lag fallthrough + +.tail: +movaps m2, [one_tab] + +mov len_pq, lag_pq +sub len_pq, mmsize + +lea data_lq, [lag_pq] +neg data_lq ; -j +add data_lq, dataq ; data[-j] + +.tail_l: +movupd m0, [dataq + len_pq] +movupd m1, [data_lq + len_pq] + +mulpd m0, m1 +addpd m2, m0; sum += data[i]*data[i-j] + +add len_pq, mmsize +cmp len_pq, lenq +jl .tail_l + +shufpd m1, m2, m2, 01b +addpd m2, m1 + +; Leave this here just in case its ever needed +%if mmsize == 32 +vperm2f128 m1, m2, m2, 0x01 +addpd xm2, xm1 +movupd [autocq + lag_pq], xm2 +%else +movhpd [autocq + lag_pq], xm2 +%endif + +.end: +%endif + +RET +%endmacro + +INIT_XMM sse2 +COMPUTE_AUTOCORR_FN +INIT_YMM avx +COMPUTE_AUTOCORR_FN diff --git a/libavcodec/x86/lpc_init.c b/libavcodec/x86/lpc_init.c index f2fca53799..bb174be53e 100644 --- a/libavcodec/x86/lpc_init.c +++ b/libavcodec/x86/lpc_init.c @@ -28,89 +28,20 @@ void ff_lpc_apply_welch_window_sse2(const int32_t *data, ptrdiff_t len, double *w_data); void ff_lpc_apply_welch_window_avx2(const int32_t *data, ptrdiff_t len, double *w_data); - -DECLARE_ASM_CONST(16, double, pd_1)[2] = { 1.0, 1.0 }; - -#if HAVE_SSE2_INLINE - -static void lpc_compute_autocorr_sse2(const double *data, ptrdiff_t len, int lag, - double *autoc) -{ -int j; - -if((x86_reg)data & 15) -data++; - -for(j=0; jlpc_compute_autocorr = lpc_compute_autocorr_sse2; -#endif +if (EXTERNAL_SSE2(cpu_flags)) +c->lpc_compute_autocorr = ff_lpc_compute_autocorr_sse2; + +if (EXTERNAL_AVX_FAST(cpu_flags)) +c->lpc_compute_autocorr = ff_lpc_compute_autocorr_avx; if (EXTERNAL_SSE2(cpu_flags)) c->lpc_apply_welch_window = ff_lpc_apply_welch_window_sse2; -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 01/10] channel_layout: add new channel positions supported by xHE-AAC
On 25/05/2024 08:10, Marton Balint wrote: On Sat, 25 May 2024, Lynne via ffmpeg-devel wrote: apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.h | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 8a078d1601..4e19bbbd9e 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, + AV_CHAN_SURROUND_LEFT, + AV_CHAN_SURROUND_RIGHT, You want to add a channel ID for Surround or Side Surround? Because based on the subsequent AAC patch you want to add it for side surround, but then the AV_CHAN_SURROUND name is confusing, since we are mapping Surround to AV_CHAN_SIDE. So I suggest using AV_CHAN_SIDE_SURROUND_LEFT/RIGHT instead. + AV_CHAN_TOP_SURROUND_LEFT, + AV_CHAN_TOP_SURROUND_RIGHT, You will need to extend the channel_names[] array in channel_layout.c with the newly added channel IDs. Thanks, changed locally. Planning on merging this in 2 days unless there are more comments. 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 v4] fate: add tests for xHE-AAC
Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. FATE files: https://files.lynne.ee/xhe_refs/ --- tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 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 v4 01/10] channel_layout: add new channel positions supported by xHE-AAC
apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.c | 4 libavutil/channel_layout.h | 8 2 files changed, 12 insertions(+) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 98839b7250..2d6963b6df 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -75,6 +75,10 @@ static const struct channel_name channel_names[] = { [AV_CHAN_BOTTOM_FRONT_CENTER ] = { "BFC", "bottom front center" }, [AV_CHAN_BOTTOM_FRONT_LEFT] = { "BFL", "bottom front left" }, [AV_CHAN_BOTTOM_FRONT_RIGHT ] = { "BFR", "bottom front right"}, +[AV_CHAN_SIDE_SURROUND_LEFT ] = { "SSL", "side surround left"}, +[AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, +[AV_CHAN_TOP_SURROUND_LEFT] = { "TTL", "top surround left" }, +[AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right"}, }; void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index b26b601065..6625313cc5 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, +AV_CHAN_SIDE_SURROUND_LEFT, +AV_CHAN_SIDE_SURROUND_RIGHT, +AV_CHAN_TOP_SURROUND_LEFT, +AV_CHAN_TOP_SURROUND_RIGHT, /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, @@ -195,6 +199,10 @@ enum AVChannelOrder { #define AV_CH_BOTTOM_FRONT_CENTER(1ULL << AV_CHAN_BOTTOM_FRONT_CENTER ) #define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT) #define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT ) +#define AV_CH_SIDE_SURROUND_LEFT (1ULL << AV_CHAN_SIDE_SURROUND_LEFT ) +#define AV_CH_SIDE_SURROUND_RIGHT(1ULL << AV_CHAN_SIDE_SURROUND_RIGHT ) +#define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT) +#define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT ) /** * @} -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 01/10] channel_layout: add new channel positions supported by xHE-AAC
On 26/05/2024 22:51, Marton Balint wrote: On Sun, 26 May 2024, Lynne via ffmpeg-devel wrote: On 25/05/2024 08:10, Marton Balint wrote: On Sat, 25 May 2024, Lynne via ffmpeg-devel wrote: apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.h | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index 8a078d1601..4e19bbbd9e 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, + AV_CHAN_SURROUND_LEFT, + AV_CHAN_SURROUND_RIGHT, You want to add a channel ID for Surround or Side Surround? Because based on the subsequent AAC patch you want to add it for side surround, but then the AV_CHAN_SURROUND name is confusing, since we are mapping Surround to AV_CHAN_SIDE. So I suggest using AV_CHAN_SIDE_SURROUND_LEFT/RIGHT instead. + AV_CHAN_TOP_SURROUND_LEFT, + AV_CHAN_TOP_SURROUND_RIGHT, You will need to extend the channel_names[] array in channel_layout.c with the newly added channel IDs. Thanks, changed locally. Planning on merging this in 2 days unless there are more comments. Can you post the updated version of this patch? It is not entirely clear what you added, or e.g. what abbriviation you planning to use for the new channel IDs. Also I noticed one more thing, you also need to add the AV_CH_* variants for the new IDs. Sure, posted. I went with exactly what you wrote. 3 days for new API such as this is a bit short, and if your AAC patches depend on it, I suggest you wait a few more days. ...its an enum entry. Do you want a design document and a proposal? You could talk to the person who did the research about it, JEEB. Why wait at all? There's only you and JEEB that care about channel layouts, you can review it and give it an LGTM. There's no reason to wait for days, that is not how reviewing is supposed to work. The decoder doesn't depend on it, I have fallback code. I've been waiting for the channel layout situation to be resolved. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v11 07/14] avcodec/vaapi_encode: extract the init and close function to base layer
On 27/05/2024 02:35, Wu, Tong1 wrote: From: ffmpeg-devel On Behalf Of Lynne via ffmpeg-devel Sent: Saturday, May 25, 2024 10:07 PM To: ffmpeg-devel@ffmpeg.org Cc: Lynne Subject: Re: [FFmpeg-devel] [PATCH v11 07/14] avcodec/vaapi_encode: extract the init and close function to base layer On 25/05/2024 12:30, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Related parameters such as device context, frame context are also moved to base layer. Signed-off-by: Tong Wu --- libavcodec/hw_base_encode.c | 49 ++ libavcodec/hw_base_encode.h | 17 +++ libavcodec/vaapi_encode.c | 90 +++-- libavcodec/vaapi_encode.h | 10 libavcodec/vaapi_encode_av1.c | 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 6 ++- 8 files changed, 102 insertions(+), 76 deletions(-) diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 16afaa37be..c4789380b6 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -592,3 +592,52 @@ end: return 0; } + +int ff_hw_base_encode_init(AVCodecContext *avctx) +{ +FFHWBaseEncodeContext *ctx = avctx->priv_data; This is the issue I was talking about, this requires that FFHWBaseEncodeContext is always the main context. Could you change it so everything takes FFHWBaseEncodeContext as an argument, rather than AVCodecContext (apart from where the function absolutely must read some data from it)? I'm trying to understand it more. In ff_hw_base_encode_init we also have the following code: if (!avctx->hw_frames_ctx) { av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is " "required to associate the encoding device.\n"); return AVERROR(EINVAL); } In this scenario we still need avctx right? So maybe this is the "must read data from it" situation and we keep AVCodecContext as the main context? Yup. My point is that FFHWBaseEncodeContext doesn't become the primary context that must be used, but a separate component other users can use standalone. Plus I have this av_log concern which is there's indeed some function that the only use of avctx is its av_log's context. Do you think I should instead use FFHWBaseEncodeContext as the main context and pass it to av_log for this situation while keeping AVCodecContext as the main context for other functions which actually read from AVCodecContext. That might lead to different av_log context in the same file. Just save a pointer to avctx on init in FFHWBaseEncodeContext. That's what most of our code does. Do you think the callbacks in FFHWEncodePictureOperation should be changed too? Or only all the functions in hw_base_encode.c should be concerned. Thank you. No, the callbacks should stay as-is. Users need to retrieve their own context via avctx. That's also a reason why you should keep a pointer to avctx on init. Thanks OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 01/10] channel_layout: add new channel positions supported by xHE-AAC
On 27/05/2024 10:40, Anton Khirnov wrote: Quoting Lynne via ffmpeg-devel (2024-05-26 23:42:41) ...its an enum entry. Do you want a design document and a proposal? You could talk to the person who did the research about it, JEEB. Why wait at all? There's only you and JEEB that care about channel layouts, you can review it and give it an LGTM. There's no reason to wait for days, that is not how reviewing is supposed to work. That's exactly how reviewing is supposed to work. Waiting a few days won't kill anyone and allows more people to comment. To the contrary I'm quite unhappy with some recent instances of developers pushing code immediately upon seeing an LGTM, without giving other people the opportunity to look at it. I'd understand if it was for generic common code, but if its for code that the one pushing it maintains, I don't see a problem with this, this is how it works in pretty much every project out there. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 01/10] channel_layout: add new channel positions supported by xHE-AAC
On 27/05/2024 11:07, Anton Khirnov wrote: Quoting Lynne via ffmpeg-devel (2024-05-27 10:54:40) On 27/05/2024 10:40, Anton Khirnov wrote: Quoting Lynne via ffmpeg-devel (2024-05-26 23:42:41) ...its an enum entry. Do you want a design document and a proposal? You could talk to the person who did the research about it, JEEB. Why wait at all? There's only you and JEEB that care about channel layouts, you can review it and give it an LGTM. There's no reason to wait for days, that is not how reviewing is supposed to work. That's exactly how reviewing is supposed to work. Waiting a few days won't kill anyone and allows more people to comment. To the contrary I'm quite unhappy with some recent instances of developers pushing code immediately upon seeing an LGTM, without giving other people the opportunity to look at it. I'd understand if it was for generic common code, but if its for code that the one pushing it maintains, I don't see a problem with this, this is how it works in pretty much every project out there. I do see a problem - just because you maintain the code doesn't mean you always understand all its aspects better than everyone, not to mention when reading your own code you tend to see what you meant to write rather than what you actually wrote. There's always a nontrivial possibility that someone could have a meaningful review comment, so why not wait a day or two? There's no harm in it. I don't get the point of this discussion, I *am* waiting for this patch, as I wait for most. But in general, it is every maintainer's discretion when they push. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/diracdec: Mark flush as av_cold
On 28/05/2024 16:03, Andreas Rheinhardt wrote: Signed-off-by: Andreas Rheinhardt --- libavcodec/diracdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c index 5bf0dcc2db..76209aebba 100644 --- a/libavcodec/diracdec.c +++ b/libavcodec/diracdec.c @@ -351,7 +351,7 @@ static int alloc_buffers(DiracContext *s, int stride) return 0; } -static void free_sequence_buffers(DiracContext *s) +static av_cold void free_sequence_buffers(DiracContext *s) { int i, j, k; @@ -413,7 +413,7 @@ static av_cold int dirac_decode_init(AVCodecContext *avctx) return 0; } -static void dirac_decode_flush(AVCodecContext *avctx) +static av_cold void dirac_decode_flush(AVCodecContext *avctx) { DiracContext *s = avctx->priv_data; free_sequence_buffers(s); Both patches look good to me. I'll remember to mark future decoders' flush with av_cold. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/7] avcodec/vc2enc: Avoid relocations for short strings
On 28/05/2024 04:49, Andreas Rheinhardt wrote: These strings are so short that they can be put directly into the containing structure, avoiding the pointer and putting it into .rodata. Also use chars for interlaced and level while at it, as these are so small. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc2enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index 3285218724..8b9641916a 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -41,8 +41,9 @@ typedef struct VC2BaseVideoFormat { enum AVPixelFormat pix_fmt; AVRational time_base; -int width, height, interlaced, level; -const char *name; +int width, height; +char interlaced, level; +char name[13]; } VC2BaseVideoFormat; static const VC2BaseVideoFormat base_video_fmts[] = { Patchset LGTM if interlaced and level are uint8_t like other commented. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v12 15/15] avcodec/hw_base_encode: add avctx pointer for FFHWBaseEncodeContext
On 28/05/2024 17:48, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu An avctx pointer is added to FFHWBaseEncodeContext. This is to make FFHWBaseEncodeContext a standalone component for ff_hw_base_* functions. This patch also removes some unnecessary AVCodecContext arguments. Signed-off-by: Tong Wu --- libavcodec/d3d12va_encode.c | 6 +++--- libavcodec/hw_base_encode.c | 31 +-- libavcodec/hw_base_encode.h | 8 +--- libavcodec/vaapi_encode.c | 6 +++--- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c index 0fbf8eb07c..6d3a53c6ca 100644 --- a/libavcodec/d3d12va_encode.c +++ b/libavcodec/d3d12va_encode.c @@ -1351,7 +1351,7 @@ static int d3d12va_encode_create_recon_frames(AVCodecContext *avctx) enum AVPixelFormat recon_format; int err; -err = ff_hw_base_get_recon_format(avctx, NULL, &recon_format); +err = ff_hw_base_get_recon_format(base_ctx, NULL, &recon_format); if (err < 0) return err; @@ -1398,7 +1398,7 @@ int ff_d3d12va_encode_init(AVCodecContext *avctx) int err; HRESULT hr; -err = ff_hw_base_encode_init(avctx); +err = ff_hw_base_encode_init(avctx, base_ctx); if (err < 0) goto fail; @@ -1552,7 +1552,7 @@ int ff_d3d12va_encode_close(AVCodecContext *avctx) D3D12_OBJECT_RELEASE(ctx->video_device3); D3D12_OBJECT_RELEASE(ctx->device3); -ff_hw_base_encode_close(avctx); +ff_hw_base_encode_close(base_ctx); return 0; } diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 92f69bb78c..88efdf672c 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -94,14 +94,13 @@ static void hw_base_encode_remove_refs(FFHWBaseEncodePicture *pic, int level) pic->ref_removed[level] = 1; } -static void hw_base_encode_set_b_pictures(AVCodecContext *avctx, +static void hw_base_encode_set_b_pictures(FFHWBaseEncodeContext *ctx, FFHWBaseEncodePicture *start, FFHWBaseEncodePicture *end, FFHWBaseEncodePicture *prev, int current_depth, FFHWBaseEncodePicture **last) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; FFHWBaseEncodePicture *pic, *next, *ref; int i, len; @@ -148,20 +147,19 @@ static void hw_base_encode_set_b_pictures(AVCodecContext *avctx, hw_base_encode_add_ref(pic, ref, 0, 1, 0); if (i > 1) -hw_base_encode_set_b_pictures(avctx, start, pic, pic, +hw_base_encode_set_b_pictures(ctx, start, pic, pic, current_depth + 1, &next); else next = pic; -hw_base_encode_set_b_pictures(avctx, pic, end, next, +hw_base_encode_set_b_pictures(ctx, pic, end, next, current_depth + 1, last); } } -static void hw_base_encode_add_next_prev(AVCodecContext *avctx, +static void hw_base_encode_add_next_prev(FFHWBaseEncodeContext *ctx, FFHWBaseEncodePicture *pic) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; int i; if (!pic) @@ -333,12 +331,12 @@ static int hw_base_encode_pick_next(AVCodecContext *avctx, } if (b_counter > 0) { -hw_base_encode_set_b_pictures(avctx, start, pic, pic, 1, +hw_base_encode_set_b_pictures(ctx, start, pic, pic, 1, &prev); } else { prev = pic; } -hw_base_encode_add_next_prev(avctx, prev); +hw_base_encode_add_next_prev(ctx, prev); return 0; } @@ -687,9 +685,9 @@ int ff_hw_base_init_gop_structure(AVCodecContext *avctx, uint32_t ref_l0, uint32 return 0; } -int ff_hw_base_get_recon_format(AVCodecContext *avctx, const void *hwconfig, enum AVPixelFormat *fmt) +int ff_hw_base_get_recon_format(FFHWBaseEncodeContext *ctx, const void *hwconfig, +enum AVPixelFormat *fmt) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; AVHWFramesConstraints *constraints = NULL; enum AVPixelFormat recon_format; int err, i; @@ -722,14 +720,14 @@ int ff_hw_base_get_recon_format(AVCodecContext *avctx, const void *hwconfig, enu // No idea what to use; copy input format. recon_format = ctx->input_frames->sw_format; } -av_log(avctx, AV_LOG_DEBUG, "Using %s as format of " +av_log(ctx->avctx, AV_LOG_DEBUG, "Using %s as format of " "reconstructed frames.\n", av_get_pix_fmt_name(recon_format)); if (ctx->surface_width < constraints->min_width || ctx->surface_height < constraints->min_height || ctx->surface_wid
Re: [FFmpeg-devel] [PATCH v12 15/15] avcodec/hw_base_encode: add avctx pointer for FFHWBaseEncodeContext
On 29/05/2024 00:53, Wu, Tong1 wrote: From: ffmpeg-devel On Behalf Of Lynne via ffmpeg-devel Sent: Wednesday, May 29, 2024 1:08 AM To: ffmpeg-devel@ffmpeg.org Cc: Lynne Subject: Re: [FFmpeg-devel] [PATCH v12 15/15] avcodec/hw_base_encode: add avctx pointer for FFHWBaseEncodeContext On 28/05/2024 17:48, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu An avctx pointer is added to FFHWBaseEncodeContext. This is to make FFHWBaseEncodeContext a standalone component for ff_hw_base_* functions. This patch also removes some unnecessary AVCodecContext arguments. Signed-off-by: Tong Wu --- libavcodec/d3d12va_encode.c | 6 +++--- libavcodec/hw_base_encode.c | 31 +-- libavcodec/hw_base_encode.h | 8 +--- libavcodec/vaapi_encode.c | 6 +++--- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c index 0fbf8eb07c..6d3a53c6ca 100644 --- a/libavcodec/d3d12va_encode.c +++ b/libavcodec/d3d12va_encode.c @@ -1351,7 +1351,7 @@ static int d3d12va_encode_create_recon_frames(AVCodecContext *avctx) enum AVPixelFormat recon_format; int err; -err = ff_hw_base_get_recon_format(avctx, NULL, &recon_format); +err = ff_hw_base_get_recon_format(base_ctx, NULL, &recon_format); if (err < 0) return err; @@ -1398,7 +1398,7 @@ int ff_d3d12va_encode_init(AVCodecContext *avctx) int err; HRESULT hr; -err = ff_hw_base_encode_init(avctx); +err = ff_hw_base_encode_init(avctx, base_ctx); if (err < 0) goto fail; @@ -1552,7 +1552,7 @@ int ff_d3d12va_encode_close(AVCodecContext *avctx) D3D12_OBJECT_RELEASE(ctx->video_device3); D3D12_OBJECT_RELEASE(ctx->device3); -ff_hw_base_encode_close(avctx); +ff_hw_base_encode_close(base_ctx); return 0; } diff --git a/libavcodec/hw_base_encode.c b/libavcodec/hw_base_encode.c index 92f69bb78c..88efdf672c 100644 --- a/libavcodec/hw_base_encode.c +++ b/libavcodec/hw_base_encode.c @@ -94,14 +94,13 @@ static void hw_base_encode_remove_refs(FFHWBaseEncodePicture *pic, int level) pic->ref_removed[level] = 1; } -static void hw_base_encode_set_b_pictures(AVCodecContext *avctx, +static void hw_base_encode_set_b_pictures(FFHWBaseEncodeContext *ctx, FFHWBaseEncodePicture *start, FFHWBaseEncodePicture *end, FFHWBaseEncodePicture *prev, int current_depth, FFHWBaseEncodePicture **last) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; FFHWBaseEncodePicture *pic, *next, *ref; int i, len; @@ -148,20 +147,19 @@ static void hw_base_encode_set_b_pictures(AVCodecContext *avctx, hw_base_encode_add_ref(pic, ref, 0, 1, 0); if (i > 1) -hw_base_encode_set_b_pictures(avctx, start, pic, pic, +hw_base_encode_set_b_pictures(ctx, start, pic, pic, current_depth + 1, &next); else next = pic; -hw_base_encode_set_b_pictures(avctx, pic, end, next, +hw_base_encode_set_b_pictures(ctx, pic, end, next, current_depth + 1, last); } } -static void hw_base_encode_add_next_prev(AVCodecContext *avctx, +static void hw_base_encode_add_next_prev(FFHWBaseEncodeContext *ctx, FFHWBaseEncodePicture *pic) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; int i; if (!pic) @@ -333,12 +331,12 @@ static int hw_base_encode_pick_next(AVCodecContext *avctx, } if (b_counter > 0) { -hw_base_encode_set_b_pictures(avctx, start, pic, pic, 1, +hw_base_encode_set_b_pictures(ctx, start, pic, pic, 1, &prev); } else { prev = pic; } -hw_base_encode_add_next_prev(avctx, prev); +hw_base_encode_add_next_prev(ctx, prev); return 0; } @@ -687,9 +685,9 @@ int ff_hw_base_init_gop_structure(AVCodecContext *avctx, uint32_t ref_l0, uint32 return 0; } -int ff_hw_base_get_recon_format(AVCodecContext *avctx, const void *hwconfig, enum AVPixelFormat *fmt) +int ff_hw_base_get_recon_format(FFHWBaseEncodeContext *ctx, const void *hwconfig, +enum AVPixelFormat *fmt) { -FFHWBaseEncodeContext *ctx = avctx->priv_data; AVHWFramesConstraints *constraints = NULL; enum AVPixelFormat recon_format; int err, i; @@ -722,14 +720,14 @@ int ff_hw_base_get_recon_format(AVCodecContext *avctx, const void *hwconfig, enu // No idea what to use; copy input format. recon_format = ctx->in
Re: [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: support applying container level cropping
On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- fftools/ffmpeg.h| 7 +++ fftools/ffmpeg_demux.c | 16 fftools/ffmpeg_filter.c | 11 +++ fftools/ffmpeg_opt.c| 3 +++ 4 files changed, 37 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fe75706afd..f908e16549 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -155,6 +155,7 @@ typedef struct OptionsContext { SpecifierOptList hwaccel_devices; SpecifierOptList hwaccel_output_formats; SpecifierOptList autorotate; +SpecifierOptList apply_cropping; /* output options */ StreamMap *stream_maps; @@ -239,6 +240,7 @@ enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), IFILTER_FLAG_CFR= (1 << 2), +IFILTER_FLAG_CROP = (1 << 3), }; typedef struct InputFilterOptions { @@ -254,6 +256,11 @@ typedef struct InputFilterOptions { * accurate */ AVRational framerate; +unsigned crop_top; +unsigned crop_bottom; +unsigned crop_left; +unsigned crop_right; + int sub2video_width; int sub2video_height; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1ca8d804ae..4178b8f840 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -66,6 +66,7 @@ typedef struct DemuxStream { int have_sub2video; int reinit_filters; int autorotate; +int apply_cropping; int wrap_correction_done; @@ -1000,11 +1001,20 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, ist->filters[ist->nb_filters - 1] = ifilter; if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { +const AVPacketSideData *sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data, + ist->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); if (ist->framerate.num > 0 && ist->framerate.den > 0) { opts->framerate = ist->framerate; opts->flags |= IFILTER_FLAG_CFR; } else opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); +if (sd && sd->size == sizeof(uint32_t) * 4) { +opts->crop_top= AV_RL32(sd->data + 0); +opts->crop_bottom = AV_RL32(sd->data + 4); +opts->crop_left = AV_RL32(sd->data + 8); +opts->crop_right = AV_RL32(sd->data + 12); +} } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the @@ -1059,6 +1069,7 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, return AVERROR(ENOMEM); opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | + IFILTER_FLAG_CROP * !!(ds->apply_cropping) | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); return ds->sch_idx_dec; @@ -1241,6 +1252,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); +ds->apply_cropping = 1; +MATCH_PER_STREAM_OPT(apply_cropping, i, ds->apply_cropping, ic, st); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); @@ -1362,6 +1376,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; +av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping, 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 12cca684b4..a31fa1be7f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1701,6 +1701,17 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, desc = av_pix_fmt_desc_get(ifp->format); av_assert0(desc); +if ((ifp->opts.flags & IFILTER_FLAG_CROP) && +!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { +char crop_buf[64]; +snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", + ifp->opts.crop_left, ifp->opts.crop_right, + ifp->opts.crop_top, ifp->opts.crop_bottom); +ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf); +if (ret < 0) +return ret; +
Re: [FFmpeg-devel] [PATCH 1/6] avcodec/packet: add a decoded frame cropping side data type
On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- libavcodec/packet.h | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavcodec/packet.h b/libavcodec/packet.h index a9a41576da..9dee035690 100644 --- a/libavcodec/packet.h +++ b/libavcodec/packet.h @@ -330,6 +330,20 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT, +/** + * The number of pixels to discard from the + * top/bottom/left/right border of the decoded frame to obtain the sub-rectangle + * intended for presentation. + * + * @code + * u32le crop_top + * u32le crop_bottom + * u32le crop_left + * u32le crop_right + * @endcode + */ +AV_PKT_DATA_FRAME_CROPPING, + /** * The number of side data types. * This is not part of the public API/ABI in the sense that it may Shouldn't this be propagated to the frame's crop fields, and back from the crop fields to the packet side-data? 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 v5 00/10] aacdec: add a native xHE-AAC decoder
This commit adds a decoder for the frequency-domain part of USAC. Changes over version 4: - Actually reset entropy decoding upon configuration. - Support for LFE channels. Lynne (10): channel_layout: add new channel positions supported by xHE-AAC 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) fate: add tests for xHE-AAC libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 371 +++--- libavcodec/aac/aacdec.h | 219 +++- libavcodec/aac/aacdec_ac.c | 208 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 | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1608 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 560 + libavcodec/aactab.h | 22 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + libavutil/channel_layout.c |4 + libavutil/channel_layout.h |8 + tests/fate/aac.mak |8 + 20 files changed, 3286 insertions(+), 235 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 v5 01/10] channel_layout: add new channel positions supported by xHE-AAC
apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.c | 4 libavutil/channel_layout.h | 8 2 files changed, 12 insertions(+) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 98839b7250..2d6963b6df 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -75,6 +75,10 @@ static const struct channel_name channel_names[] = { [AV_CHAN_BOTTOM_FRONT_CENTER ] = { "BFC", "bottom front center" }, [AV_CHAN_BOTTOM_FRONT_LEFT] = { "BFL", "bottom front left" }, [AV_CHAN_BOTTOM_FRONT_RIGHT ] = { "BFR", "bottom front right"}, +[AV_CHAN_SIDE_SURROUND_LEFT ] = { "SSL", "side surround left"}, +[AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, +[AV_CHAN_TOP_SURROUND_LEFT] = { "TTL", "top surround left" }, +[AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right"}, }; void av_channel_name_bprint(AVBPrint *bp, enum AVChannel channel_id) diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h index b26b601065..3a96c2d9b8 100644 --- a/libavutil/channel_layout.h +++ b/libavutil/channel_layout.h @@ -79,6 +79,10 @@ enum AVChannel { AV_CHAN_BOTTOM_FRONT_CENTER, AV_CHAN_BOTTOM_FRONT_LEFT, AV_CHAN_BOTTOM_FRONT_RIGHT, +AV_CHAN_SIDE_SURROUND_LEFT, ///< +90 degrees, Lss, SiL +AV_CHAN_SIDE_SURROUND_RIGHT,///< -90 degrees, Rss, SiR +AV_CHAN_TOP_SURROUND_LEFT, ///< +110 degrees, Lvs, TpLS +AV_CHAN_TOP_SURROUND_RIGHT, ///< -110 degrees, Rvs, TpRS /** Channel is empty can be safely skipped. */ AV_CHAN_UNUSED = 0x200, @@ -195,6 +199,10 @@ enum AVChannelOrder { #define AV_CH_BOTTOM_FRONT_CENTER(1ULL << AV_CHAN_BOTTOM_FRONT_CENTER ) #define AV_CH_BOTTOM_FRONT_LEFT (1ULL << AV_CHAN_BOTTOM_FRONT_LEFT) #define AV_CH_BOTTOM_FRONT_RIGHT (1ULL << AV_CHAN_BOTTOM_FRONT_RIGHT ) +#define AV_CH_SIDE_SURROUND_LEFT (1ULL << AV_CHAN_SIDE_SURROUND_LEFT ) +#define AV_CH_SIDE_SURROUND_RIGHT(1ULL << AV_CHAN_SIDE_SURROUND_RIGHT ) +#define AV_CH_TOP_SURROUND_LEFT (1ULL << AV_CHAN_TOP_SURROUND_LEFT) +#define AV_CH_TOP_SURROUND_RIGHT (1ULL << AV_CHAN_TOP_SURROUND_RIGHT ) /** * @} -- 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 v5 02/10] 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/aacdec.c | 100 --- libavcodec/aac/aacdec.h | 5 +- libavcodec/aac/aacdec_dsp_template.c | 95 ++--- 3 files changed, 83 insertions(+), 117 deletions(-) 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; case INTENSITY_BT: /* fallthrough */ case INTENSITY_BT2: -for (; i < run_end; i++, idx++) { -offset[2] += get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - SCALE_DIFF_ZERO; -clipped_offset = av_clip(offset[2], -155, 100); -if (offset[2] != clipped_offset) { -avpriv_request_sample(ac->avctx, - "If you heard an audible artifact, there may be a bug in the decoder. " - "Clipped intensity stereo position (%d -> %d)", - offset[2], clipped_offset);
[FFmpeg-devel] [PATCH v5 03/10] 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 v5 04/10] 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 bea0578e92..499bd8eefc 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 v5 05/10] 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 499bd8eefc..8d1eb74066 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 v5 06/10] 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 v5 08/10] 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 v5 09/10] 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) - Stereo (complex prediction) What's left: - Speech coding Known issues: - Desync with certain sequences - Preroll crossover missing (shouldn't matter, bitrate adaptation only) --- libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 188 +-- libavcodec/aac/aacdec.h | 187 +++ libavcodec/aac/aacdec_ac.c | 208 libavcodec/aac/aacdec_ac.h | 54 + libavcodec/aac/aacdec_dsp_template.c |4 +- libavcodec/aac/aacdec_latm.h | 14 +- libavcodec/aac/aacdec_lpd.c | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1608 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 42 + libavcodec/aactab.h | 10 + 13 files changed, 2510 insertions(+), 76 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 c3e525d373..70b1dca274 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 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..2b8322fc68 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 re
[FFmpeg-devel] [PATCH v5 07/10] 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, +
[FFmpeg-devel] [PATCH v5 10/10] fate: add tests for xHE-AAC
Starting off small with a few features. Samples and reference decoded files copied from the official ISO reference suite. FATE files: https://files.lynne.ee/xhe_refs/ --- tests/fate/aac.mak | 8 1 file changed, 8 insertions(+) diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak index 817944773d..ff58392ad9 100644 --- a/tests/fate/aac.mak +++ b/tests/fate/aac.mak @@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16 +FATE_AAC += fate-aac-fd_2_c1_ms_0x01 +fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4 +fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16 + +FATE_AAC += fate-aac-fd_2_c1_ms_0x04 +fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i $(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4 +fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16 + FATE_AAC += fate-aac-er_ad6000np_44_ep0 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i $(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16 -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 01/10, v3] avutil: add hwcontext_amf.
On 30/05/2024 15:08, Dmitrii Ovchinnikov wrote: Adds hwcontext_amf, which allows to use shared AMF context for the encoder, decoder and AMF-based filters, without copy to the host memory. It will also allow you to use some optimisations in the interaction of components (for example, SAV) and make a more manageable and optimal setup for using GPU devices with AMF in the case of a fully AMF pipeline. It will be a significant performance uplift when full AMF pipeline with filters is used. We also plan to add Compression artefact removal filter in near feature. v2: cleanup header files v3: an unnecessary class has been removed. --- libavutil/Makefile | 4 + libavutil/hwcontext.c | 4 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_amf.c | 585 + libavutil/hwcontext_amf.h | 64 libavutil/hwcontext_amf_internal.h | 44 +++ libavutil/hwcontext_internal.h | 1 + libavutil/pixdesc.c| 4 + libavutil/pixfmt.h | 5 + 9 files changed, 712 insertions(+) create mode 100644 libavutil/hwcontext_amf.c create mode 100644 libavutil/hwcontext_amf.h create mode 100644 libavutil/hwcontext_amf_internal.h Still no answer to my question? OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 01/10, v3] avutil: add hwcontext_amf.
On 30/05/2024 18:06, Dmitrii Ovchinnikov wrote: DX12 and Vulkan native encoders will expose less features compare to AMF, at least in foreseeable feature. The missing features include low latency, That's plainly not true. PreAnalysis including look-ahead etc. AMF context on Windows allows fully enable SAV - ability to utilize VCNs in dGPU and APU in a single session. You should try talking internally to learn what is in progress. AMF components including encoder and decoder has some internal optimizations in the area of memory access for APUs that are not available in standard 3D APIs. This isn't OpenGL. Eventually specialized multimedia AMD cards could be added seamlessly to FFmpeg with AMF integration. AMF FSR(VSR) includes YUV version with focus on videos which is not available in AMD FSR aimed for gaming. Why don't you open source it then? More advanced filters that are not available in standard 3D APIs are coming. __ We could have them as Vulkan filters. I'm not objecting on this patch, but I am concerned that it's more proprietary code which is soon going to be redundant. I will have to review it properly at some point. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/6] fftools/ffmpeg: support applying container level cropping
On 30/05/2024 03:04, James Almer wrote: On 5/29/2024 10:01 PM, Lynne via ffmpeg-devel wrote: On 29/05/2024 23:46, James Almer wrote: Signed-off-by: James Almer --- fftools/ffmpeg.h | 7 +++ fftools/ffmpeg_demux.c | 16 fftools/ffmpeg_filter.c | 11 +++ fftools/ffmpeg_opt.c | 3 +++ 4 files changed, 37 insertions(+) diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index fe75706afd..f908e16549 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -155,6 +155,7 @@ typedef struct OptionsContext { SpecifierOptList hwaccel_devices; SpecifierOptList hwaccel_output_formats; SpecifierOptList autorotate; + SpecifierOptList apply_cropping; /* output options */ StreamMap *stream_maps; @@ -239,6 +240,7 @@ enum IFilterFlags { IFILTER_FLAG_AUTOROTATE = (1 << 0), IFILTER_FLAG_REINIT = (1 << 1), IFILTER_FLAG_CFR = (1 << 2), + IFILTER_FLAG_CROP = (1 << 3), }; typedef struct InputFilterOptions { @@ -254,6 +256,11 @@ typedef struct InputFilterOptions { * accurate */ AVRational framerate; + unsigned crop_top; + unsigned crop_bottom; + unsigned crop_left; + unsigned crop_right; + int sub2video_width; int sub2video_height; diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1ca8d804ae..4178b8f840 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -66,6 +66,7 @@ typedef struct DemuxStream { int have_sub2video; int reinit_filters; int autorotate; + int apply_cropping; int wrap_correction_done; @@ -1000,11 +1001,20 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, ist->filters[ist->nb_filters - 1] = ifilter; if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) { + const AVPacketSideData *sd = av_packet_side_data_get(ist->st->codecpar->coded_side_data, + ist->st->codecpar->nb_coded_side_data, + AV_PKT_DATA_FRAME_CROPPING); if (ist->framerate.num > 0 && ist->framerate.den > 0) { opts->framerate = ist->framerate; opts->flags |= IFILTER_FLAG_CFR; } else opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL); + if (sd && sd->size == sizeof(uint32_t) * 4) { + opts->crop_top = AV_RL32(sd->data + 0); + opts->crop_bottom = AV_RL32(sd->data + 4); + opts->crop_left = AV_RL32(sd->data + 8); + opts->crop_right = AV_RL32(sd->data + 12); + } } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* Compute the size of the canvas for the subtitles stream. If the subtitles codecpar has set a size, use it. Otherwise use the @@ -1059,6 +1069,7 @@ int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, return AVERROR(ENOMEM); opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ds->autorotate) | + IFILTER_FLAG_CROP * !!(ds->apply_cropping) | IFILTER_FLAG_REINIT * !!(ds->reinit_filters); return ds->sch_idx_dec; @@ -1241,6 +1252,9 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->autorotate = 1; MATCH_PER_STREAM_OPT(autorotate, i, ds->autorotate, ic, st); + ds->apply_cropping = 1; + MATCH_PER_STREAM_OPT(apply_cropping, i, ds->apply_cropping, ic, st); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); @@ -1362,6 +1376,8 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st) ds->dec_opts.flags |= DECODER_FLAG_BITEXACT * !!o->bitexact; + av_dict_set_int(&ds->decoder_opts, "apply_cropping", ds->apply_cropping, 0); + /* Attached pics are sparse, therefore we would not want to delay their decoding * till EOF. */ if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 12cca684b4..a31fa1be7f 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1701,6 +1701,17 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph, desc = av_pix_fmt_desc_get(ifp->format); av_assert0(desc); + if ((ifp->opts.flags & IFILTER_FLAG_CROP) && + !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) { + char crop_buf[64]; + snprintf(crop_buf, sizeof(crop_buf), "w=iw-%d-%d:h=ih-%d-%d", + ifp->opts.crop_left, ifp->opts.crop_right,
Re: [FFmpeg-devel] [PATCH v5 01/10] channel_layout: add new channel positions supported by xHE-AAC
On 31/05/2024 15:39, Jan Ekström wrote: On Thu, May 30, 2024 at 5:39 AM Lynne via ffmpeg-devel wrote: apichanges will be updated upon merging, as well as a version bump. --- libavutil/channel_layout.c | 4 libavutil/channel_layout.h | 8 2 files changed, 12 insertions(+) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 98839b7250..2d6963b6df 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -75,6 +75,10 @@ static const struct channel_name channel_names[] = { [AV_CHAN_BOTTOM_FRONT_CENTER ] = { "BFC", "bottom front center" }, [AV_CHAN_BOTTOM_FRONT_LEFT] = { "BFL", "bottom front left" }, [AV_CHAN_BOTTOM_FRONT_RIGHT ] = { "BFR", "bottom front right" }, +[AV_CHAN_SIDE_SURROUND_LEFT ] = { "SSL", "side surround left"}, +[AV_CHAN_SIDE_SURROUND_RIGHT ] = { "SSR", "side surround right" }, +[AV_CHAN_TOP_SURROUND_LEFT] = { "TTL", "top surround left" }, +[AV_CHAN_TOP_SURROUND_RIGHT ] = { "TTR", "top surround right"}, Just noticed for these two top ones, is there a connection being "TTL" and "top surround left" that I somehow missed, or is this a typo of "TSL"? TSL and TSR are already taken: > [AV_CHAN_TOP_SIDE_LEFT] = { "TSL", "top side left" }, > [AV_CHAN_TOP_SIDE_RIGHT ] = { "TSR", "top side right" }, I tried using "Beside" instead of side, which would have resulted in "TBR" and "TBL", but those are taken by Top Back Left/Right. So I went with the short form of "Top Top Left" and "Top Top Right" without putting too much thought. OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCHv6] checkasm/lpc: test compute_autocorr
On 31/05/2024 19:51, Rémi Denis-Courmont wrote: --- tests/checkasm/lpc.c | 57 ++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/tests/checkasm/lpc.c b/tests/checkasm/lpc.c index 592e34c03d..62232fdaf7 100644 --- a/tests/checkasm/lpc.c +++ b/tests/checkasm/lpc.c @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "libavutil/avassert.h" #include "libavutil/mem_internal.h" #include "libavcodec/lpc.h" @@ -57,10 +58,51 @@ static void test_window(int len) bench_new(src, len, dst1); } +#if !ARCH_X86 +static void test_compute_autocorr(ptrdiff_t len, int lag) +{ +const double eps = EPS * (double)len; +LOCAL_ALIGNED(32, double, src, [5000 + 2 + MAX_LPC_ORDER]); +LOCAL_ALIGNED(16, double, dst0, [MAX_LPC_ORDER + 1]); +LOCAL_ALIGNED(16, double, dst1, [MAX_LPC_ORDER + 1]); + +declare_func(void, const double *in, ptrdiff_t len, int lag, double *out); + +av_assert0(lag >= 0 && lag <= MAX_LPC_ORDER); + +for (int i = 0; i < MAX_LPC_ORDER; i++) +src[i] = 0.; + +src += MAX_LPC_ORDER; + +for (int i = 0; i < 5000 + 2; i++) { +src[i] = (double)rnd() / (double)UINT_MAX; +} + +call_ref(src, len, lag, dst0); +call_new(src, len, lag, dst1); + +for (size_t i = 0; i <= lag; i++) { +if (!double_near_abs_eps(dst0[i], dst1[i], eps)) { +fprintf(stderr, "%zu: %- .12f - %- .12f = % .12g\n", +i, dst0[i], dst1[i], dst0[i] - dst1[i]); +fail(); +break; +} +} + +bench_new(src, 4608, lag, dst1); +} +#endif + void checkasm_check_lpc(void) { LPCContext ctx; -int len = rnd() % 5000; +int len = 2000 + rnd() % 3000; Please don't randomize the length in tests. Pick a few lengths to check all corner cases. Checkasm tests should be deterministic in how long it takes to run them between invocations. +#if !ARCH_X86 +static const int lags[] = { 8, 12, }; +#endif + ff_lpc_init(&ctx, 32, 16, FF_LPC_TYPE_DEFAULT); if (check_func(ctx.lpc_apply_welch_window, "apply_welch_window_even")) { @@ -72,6 +114,17 @@ void checkasm_check_lpc(void) test_window(len | 1); } report("apply_welch_window_odd"); - ff_lpc_end(&ctx); + +#if !ARCH_X86 +for (size_t i = 0; i < FF_ARRAY_ELEMS(lags); i++) { +ff_lpc_init(&ctx, len, lags[i], FF_LPC_TYPE_DEFAULT); +if (check_func(ctx.lpc_compute_autocorr, "autocorr_%d", lags[i])) { +test_compute_autocorr(len & ~1, lags[i]); +test_compute_autocorr(len | 1, lags[i]); +} +ff_lpc_end(&ctx); +} +report("compute_autocorr"); +#endif } OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] checkasm: add aacencdsp.quant_bands test
On 31/05/2024 20:18, Rémi Denis-Courmont wrote: --- tests/checkasm/aacencdsp.c | 37 + 1 file changed, 37 insertions(+) diff --git a/tests/checkasm/aacencdsp.c b/tests/checkasm/aacencdsp.c index 1756c4ecd5..756f92fd8f 100644 --- a/tests/checkasm/aacencdsp.c +++ b/tests/checkasm/aacencdsp.c @@ -22,7 +22,9 @@ #include "libavutil/mem_internal.h" +#include "libavcodec/aacenc_utils.h" #include "libavcodec/aacencdsp.h" +#include "libavcodec/aactab.h" #include "checkasm.h" @@ -35,6 +37,8 @@ } \ } while (0) +#define randomize_elem(tab) (tab[rnd() % FF_ARRAY_ELEMS(tab)]) + static void test_abs_pow34(AACEncDSPContext *s) { #define BUF_SIZE 1024 @@ -60,6 +64,38 @@ static void test_abs_pow34(AACEncDSPContext *s) report("abs_pow34"); } +static void test_quant_bands(AACEncDSPContext *s) +{ +int maxval = randomize_elem(aac_cb_maxval); +float q34 = randomize_elem(ff_aac_pow34sf_tab); +float rounding = (rnd() & 1) ? ROUND_TO_ZERO : ROUND_STANDARD; +LOCAL_ALIGNED_32(float, in, [BUF_SIZE]); +LOCAL_ALIGNED_32(float, scaled, [BUF_SIZE]); + +declare_func(void, int *, const float *, const float *, int, int, int, + const float, const float); + +randomize_float(in, BUF_SIZE); +randomize_float(scaled, BUF_SIZE); + +for (int sign = 0; sign <= 1; sign++) { +if (check_func(s->quant_bands, "quant_bands_%s", + sign ? "signed" : "unsigned")) { +LOCAL_ALIGNED_32(int, out, [BUF_SIZE]); +LOCAL_ALIGNED_32(int, out2, [BUF_SIZE]); + +call_ref(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); +call_new(out2, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); + +if (memcmp(out, out2, BUF_SIZE * sizeof (int))) +fail(); + +bench_new(out, in, scaled, BUF_SIZE, sign, maxval, q34, rounding); +} +} + +report("abs_pow34"); +} void checkasm_check_aacencdsp(void) { @@ -67,4 +103,5 @@ void checkasm_check_aacencdsp(void) ff_aacenc_dsp_init(&s); test_abs_pow34(&s); +test_quant_bands(&s); } LGTM OpenPGP_0xA2FEA5F03F034464.asc Description: OpenPGP public key OpenPGP_signature.asc Description: OpenPGP digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCHv6] checkasm/lpc: test compute_autocorr
On 31/05/2024 20:29, Rémi Denis-Courmont wrote: Le perjantaina 31. toukokuuta 2024, 21.23.43 EEST Lynne via ffmpeg-devel a écrit : Please don't randomize the length in tests. Pick a few lengths to check all corner cases. Checkasm tests should be deterministic in how long it takes to run them between invocations. I agree, but that problem was introduced by a1c6f4b653b6fca51eea40f12a22ab1cb045751d, and I have no pretense to fix it in this patch. Frankly, this test has outlived its usefulness for my purposes and I have had enough rebasing it again and again and again and again and again due to mostly external problems. As far as I am concerned, this is now dropped. Are you going to submit a new test, or? 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] web: add a note about xHE-AAC
--- src/index | 12 1 file changed, 12 insertions(+) diff --git a/src/index b/src/index index 442db4b..920a5bb 100644 --- a/src/index +++ b/src/index @@ -35,6 +35,18 @@ News + June 2rd, 2024, native xHE-AAC decoder + + FFmpeg now implements a native xHE-AAC decoder. Currently, streams without (e)SBR, USAC or MPEG-H Surround + are supported, which means the majority of xHE-AAC streams in use should work. Support for USAC and (e)SBR is + coming soon, as well as performance optimizations. Work is ongoing to improve its stability and compatibility. + During the process we found several specification issues, which were then submitted back to the authors + for discussion and potential inclusion in a future errata. + + + We recommend using Opus. + + May 13th, 2024, Sovereign Tech Fund The FFmpeg community is excited to announce that Germany's -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 00/10] aacdec: add a native xHE-AAC decoder
On 30/05/2024 04:37, Lynne wrote: This commit adds a decoder for the frequency-domain part of USAC. Changes over version 4: - Actually reset entropy decoding upon configuration. - Support for LFE channels. Lynne (10): channel_layout: add new channel positions supported by xHE-AAC 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) fate: add tests for xHE-AAC libavcodec/aac/Makefile |3 +- libavcodec/aac/aacdec.c | 371 +++--- libavcodec/aac/aacdec.h | 219 +++- libavcodec/aac/aacdec_ac.c | 208 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 | 198 libavcodec/aac/aacdec_lpd.h | 33 + libavcodec/aac/aacdec_usac.c | 1608 ++ libavcodec/aac/aacdec_usac.h | 37 + libavcodec/aactab.c | 560 + libavcodec/aactab.h | 22 + libavcodec/sinewin_fixed_tablegen.c |2 + libavcodec/sinewin_fixed_tablegen.h |4 + libavutil/channel_layout.c |4 + libavutil/channel_layout.h |8 + tests/fate/aac.mak |8 + 20 files changed, 3286 insertions(+), 235 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 Patchset pushed. Thanks for the reviews. 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] lavu: bump minor and add APIchanges entries for the new channel positions
--- doc/APIchanges | 6 ++ libavutil/version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 60f056b863..e36a01336c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,12 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-06-02 - xx - lavu 59.21.100 - channel_layout.h + Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_LEFT. + Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_RIGHT. + Add AV_CHAN_TOP_SURROUND_LEFT and AV_CH_TOP_SURROUND_LEFT. + Add AV_CHAN_TOP_SURROUND_RIGHT and AV_CH_TOP_SURROUND_RIGHT. + 2024-05-23 - xx - lavu 59.20.100 - channel_layout.h Add av_channel_layout_ambisonic_order(). diff --git a/libavutil/version.h b/libavutil/version.h index 9c7146c228..9d08d56884 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 21 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 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] codec_desc: drop INTRA_ONLY flag for AAC
Not valid anymore with xHE-AAC. --- libavcodec/codec_desc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index a28ef68061..a3b983b907 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2697,7 +2697,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_AUDIO, .name = "aac", .long_name = NULL_IF_CONFIG_SMALL("AAC (Advanced Audio Coding)"), -.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +.props = AV_CODEC_PROP_LOSSY, .profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), }, { @@ -3031,7 +3031,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .type = AVMEDIA_TYPE_AUDIO, .name = "aac_latm", .long_name = NULL_IF_CONFIG_SMALL("AAC LATM (Advanced Audio Coding LATM syntax)"), -.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +.props = AV_CODEC_PROP_LOSSY, .profiles = NULL_IF_CONFIG_SMALL(ff_aac_profiles), }, { -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] lavu: bump minor and add APIchanges entries for the new channel positions
On 02/06/2024 19:13, James Almer wrote: On 6/2/2024 2:10 PM, Lynne via ffmpeg-devel wrote: --- doc/APIchanges | 6 ++ libavutil/version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 60f056b863..e36a01336c 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,12 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-06-02 - xx - lavu 59.21.100 - channel_layout.h + Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_LEFT. + Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_RIGHT. + Add AV_CHAN_TOP_SURROUND_LEFT and AV_CH_TOP_SURROUND_LEFT. + Add AV_CHAN_TOP_SURROUND_RIGHT and AV_CH_TOP_SURROUND_RIGHT. + 2024-05-23 - xx - lavu 59.20.100 - channel_layout.h Add av_channel_layout_ambisonic_order(). diff --git a/libavutil/version.h b/libavutil/version.h index 9c7146c228..9d08d56884 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 21 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LGTM. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". Pushed, thanks. 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 1/4] aacdec_usac: prevent get_bits(0) in get_escaped_value
Some calls to get_escaped_value() specify 0 bits as the third value. This would result in get_bits(0), which is not a correct usage of the get_bits API. --- libavcodec/aac/aacdec_usac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 00ec74718b..d98c014cf8 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -38,7 +38,7 @@ static inline uint32_t get_escaped_value(GetBitContext *gb, int nb1, int nb2, in return val; val += val2 = get_bits(gb, nb2); -if (val2 == ((1 << nb2) - 1)) +if (nb3 && (val2 == ((1 << nb2) - 1))) val += get_bits(gb, nb3); return val; -- 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/4] aacdec_usac: error out on too many elements
USAC supports up to 64 audio channels, but puts no limit on the total number of extensions that may be present. Which may mean that there's a single audio channel, with 65 thousand extension elements. We assume that 64 elements is the maximum for now. So check the value. --- libavcodec/aac/aacdec_usac.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index d98c014cf8..af3df3b449 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -393,6 +393,11 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, /* UsacDecoderConfig */ elem_id[0] = elem_id[1] = elem_id[2] = 0; usac->nb_elems = get_escaped_value(gb, 4, 8, 16) + 1; +if (usac->nb_elems > 64) { +av_log(ac->avctx, AV_LOG_ERROR, "Too many elements: %i\n", + usac->nb_elems); +return AVERROR(EINVAL); +} for (int i = 0; i < usac->nb_elems; i++) { AACUsacElemConfig *e = &usac->elems[i]; -- 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 3/4] aacdec_usac: error out on receiving too many channels for the current layout
Verify that we have a correct number of channels. --- libavcodec/aac/aacdec_usac.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index af3df3b449..0d5eb59de5 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -311,7 +311,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, int ret, idx; uint8_t freq_idx; uint8_t channel_config_idx; -int nb_elements; +int nb_channels = 0; int samplerate; int sbr_ratio; MPEG4AudioConfig *m4ac = &oc->m4ac; @@ -358,7 +358,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, channel_config_idx = get_bits(gb, 5); /* channelConfigurationIndex */ if (!channel_config_idx) { /* UsacChannelConfig() */ -uint8_t nb_channels = get_escaped_value(gb, 5, 8, 16); /* numOutChannels */ +nb_channels = get_escaped_value(gb, 5, 8, 16); /* numOutChannels */ if (nb_channels >= 64) return AVERROR(EINVAL); @@ -385,9 +385,14 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, if (ret < 0) return ret; } else { +int nb_elements; if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map, &nb_elements, channel_config_idx))) return ret; + +/* Fill in the number of expected channels */ +for (int i = 0; i < nb_elements; i++) +nb_channels += layout_map[i][0] == TYPE_CPE ? 2 : 1; } /* UsacDecoderConfig */ @@ -404,6 +409,13 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, memset(e, 0, sizeof(*e)); e->type = get_bits(gb, 2); /* usacElementType */ +if (e->type != ID_USAC_EXT && +elem_id[0] + elem_id[1] + elem_id[2] + 1 > nb_channels) { +av_log(ac->avctx, AV_LOG_ERROR, "Too many channels for the channel " +"configuration\n"); +return AVERROR(EINVAL); +} + av_log(ac->avctx, AV_LOG_DEBUG, "Element present: idx %i, type %i\n", i, e->type); -- 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 4/4] aacdec_usac: fix off by one error check on channel numbers
--- libavcodec/aac/aacdec_usac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 0d5eb59de5..80c6ab4e65 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -359,7 +359,7 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, if (!channel_config_idx) { /* UsacChannelConfig() */ nb_channels = get_escaped_value(gb, 5, 8, 16); /* numOutChannels */ -if (nb_channels >= 64) +if (nb_channels > 64) return AVERROR(EINVAL); av_channel_layout_uninit(&ac->oc[1].ch_layout); -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/aac/aacdec_usac: remove unnecessary cast
On 03/06/2024 01:14, James Almer wrote: Fixes "libavcodec/aac/aacdec_usac.c(543): error C2440: 'type cast': cannot convert from 'GetBitContext' to 'GetBitContext'" from msvc. That's a very weird error. Why would they not permit casts of the same type? Signed-off-by: James Almer --- libavcodec/aac/aacdec_usac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 00ec74718b..c76d72d7a7 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -540,7 +540,7 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, float coef[1024], c = ff_aac_ac_map_process(state, reset, N); /* Backup reader for rolling back by 14 bits at the end */ -gb2 = (GetBitContext)*gb; +gb2 = *gb; gb_count = get_bits_count(&gb2); for (i = 0; i < len/2; i++) { LGTM, tnx 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 4/4] lavc: bump minor and add APIchanges entry for new USAC profile
--- doc/APIchanges | 3 +++ libavcodec/version.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index e36a01336c..d9bec790a3 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-06-05 - xx - lavc 61.7.100 - avcodec.h, defs.h + Add FF_PROFILE_AAC_USAC and AV_PROFILE_AAC_USAC. + 2024-06-02 - xx - lavu 59.21.100 - channel_layout.h Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_LEFT. Add AV_CHAN_SIDE_SURROUND_RIGHT and AV_CH_SIDE_SURROUND_RIGHT. diff --git a/libavcodec/version.h b/libavcodec/version.h index da54f87887..7acb261bb3 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 6 +#define LIBAVCODEC_VERSION_MINOR 7 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ -- 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/4] mpeg4audio: rename AOT_USAC_NOSBR to AOT_USAC
The issue is that AOT 45 isn't defined anywhere, and looking at the git blame, it seems to have sprung up through a reordering of the enum, and adding a hole. The spec does not define an explicit AOT for SBR and no SBR, and only uses AOT 42 (previously AOT_USAC_NOSBR), so just rename AOT_USAC to it and replace its use everywhere. --- libavcodec/aac/aacdec.c | 7 ++- libavcodec/mpeg4audio.h | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c index 2b8322fc68..24d2bdde4c 100644 --- a/libavcodec/aac/aacdec.c +++ b/libavcodec/aac/aacdec.c @@ -1046,7 +1046,6 @@ static int decode_audio_specific_config_gb(AACDecContext *ac, 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) @@ -1571,8 +1570,7 @@ int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns, GetBitContext *gb, const IndividualChannelStream *ics) { int tns_max_order = INT32_MAX; -const int is_usac = ac->oc[1].m4ac.object_type == AOT_USAC || -ac->oc[1].m4ac.object_type == AOT_USAC_NOSBR; +const int is_usac = ac->oc[1].m4ac.object_type == AOT_USAC; int w, filt, i, coef_len, coef_res, coef_compress; const int is8 = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE; @@ -2421,8 +2419,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, AVFrame *frame, ac->tags_mapped = 0; -if ((ac->oc[1].m4ac.object_type == AOT_USAC) || -(ac->oc[1].m4ac.object_type == AOT_USAC_NOSBR)) { +if (ac->oc[1].m4ac.object_type == AOT_USAC) { if (ac->is_fixed) { avpriv_report_missing_feature(ac->avctx, "AAC USAC fixed-point decoding"); diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index 56615ef321..5daba7824b 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -108,10 +108,9 @@ enum AudioObjectType { AOT_ER_AAC_ELD,///< N Error Resilient Enhanced Low Delay AOT_SMR_SIMPLE,///< N Symbolic Music Representation Simple AOT_SMR_MAIN, ///< N Symbolic Music Representation Main -AOT_USAC_NOSBR,///< N Unified Speech and Audio Coding (no SBR) +AOT_USAC, ///< Y Unified Speech and Audio Coding AOT_SAOC, ///< N Spatial Audio Object Coding AOT_LD_SURROUND, ///< N Low Delay MPEG Surround -AOT_USAC, ///< N Unified Speech and Audio Coding }; #define MAX_PCE_SIZE 320 ///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/4] aac: define a new profile for USAC
This allows users to determine whether a stream is USAC or not. --- libavcodec/aac/aacdec_usac.c | 4 libavcodec/avcodec.h | 1 + libavcodec/defs.h| 1 + libavcodec/profiles.c| 1 + libavcodec/profiles.h| 1 + 5 files changed, 8 insertions(+) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 7b36b49d63..5c3bb8d4ac 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -494,6 +494,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, } } +ac->avctx->profile = AV_PROFILE_AAC_USAC; + ret = ff_aac_usac_reset_state(ac, oc); if (ret < 0) return ret; @@ -1533,6 +1535,8 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, ac->oc[1].status, 0); +ac->avctx->profile = AV_PROFILE_AAC_USAC; + indep_flag = get_bits1(gb); nb_ch_el = 0; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2da63c87ea..257e04fe2d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1652,6 +1652,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_AAC_HE_V2 28 #define FF_PROFILE_AAC_LD 22 #define FF_PROFILE_AAC_ELD 38 +#define FF_PROFILE_AAC_USAC 41 #define FF_PROFILE_MPEG2_AAC_LOW 128 #define FF_PROFILE_MPEG2_AAC_HE 131 diff --git a/libavcodec/defs.h b/libavcodec/defs.h index 00d840ec19..7ddfdcad0b 100644 --- a/libavcodec/defs.h +++ b/libavcodec/defs.h @@ -73,6 +73,7 @@ #define AV_PROFILE_AAC_HE_V2 28 #define AV_PROFILE_AAC_LD 22 #define AV_PROFILE_AAC_ELD 38 +#define AV_PROFILE_AAC_USAC41 #define AV_PROFILE_MPEG2_AAC_LOW 128 #define AV_PROFILE_MPEG2_AAC_HE 131 diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 052b77926e..44bdf6f85b 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -33,6 +33,7 @@ const AVProfile ff_aac_profiles[] = { { AV_PROFILE_AAC_MAIN, "Main" }, { AV_PROFILE_AAC_SSR, "SSR" }, { AV_PROFILE_AAC_LTP, "LTP" }, +{ AV_PROFILE_AAC_USAC, "xHE-AAC" }, { AV_PROFILE_UNKNOWN }, }; diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h index 842201718b..33b7ffc17a 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -35,6 +35,7 @@ FF_AVCTX_PROFILE_OPTION("aac_he_v2", NULL, AUDIO, AV_PROFILE_AAC_HE_V2)\ FF_AVCTX_PROFILE_OPTION("aac_ld",NULL, AUDIO, AV_PROFILE_AAC_LD)\ FF_AVCTX_PROFILE_OPTION("aac_eld", NULL, AUDIO, AV_PROFILE_AAC_ELD)\ +FF_AVCTX_PROFILE_OPTION("aac_xhe", NULL, AUDIO, AV_PROFILE_AAC_USAC)\ FF_AVCTX_PROFILE_OPTION("mpeg2_aac_low", NULL, AUDIO, AV_PROFILE_MPEG2_AAC_LOW)\ FF_AVCTX_PROFILE_OPTION("mpeg2_aac_he", NULL, AUDIO, AV_PROFILE_MPEG2_AAC_HE)\ -- 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/4] mpeg4audio: explicitly define each AOT
This makes it far easier to figure out which AOT belongs to which profile. Also, explicitly highlight the holes. --- libavcodec/mpeg4audio.h | 82 + 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h index 5daba7824b..0819e48a42 100644 --- a/libavcodec/mpeg4audio.h +++ b/libavcodec/mpeg4audio.h @@ -68,49 +68,51 @@ int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf, int size, int sync_extension, void *logctx); enum AudioObjectType { -AOT_NULL, +AOT_NULL = 0, // Support?Name -AOT_AAC_MAIN, ///< Y Main -AOT_AAC_LC,///< Y Low Complexity -AOT_AAC_SSR, ///< N (code in SoC repo)Scalable Sample Rate -AOT_AAC_LTP, ///< Y Long Term Prediction -AOT_SBR, ///< Y Spectral Band Replication -AOT_AAC_SCALABLE, ///< N Scalable -AOT_TWINVQ,///< N Twin Vector Quantizer -AOT_CELP, ///< N Code Excited Linear Prediction -AOT_HVXC, ///< N Harmonic Vector eXcitation Coding +AOT_AAC_MAIN = 1, ///< Y Main +AOT_AAC_LC = 2, ///< Y Low Complexity +AOT_AAC_SSR = 3, ///< N (code in SoC repo)Scalable Sample Rate +AOT_AAC_LTP = 4, ///< Y Long Term Prediction +AOT_SBR = 5, ///< Y Spectral Band Replication +AOT_AAC_SCALABLE = 6, ///< N Scalable +AOT_TWINVQ = 7, ///< N Twin Vector Quantizer +AOT_CELP = 8, ///< N Code Excited Linear Prediction +AOT_HVXC = 9, ///< N Harmonic Vector eXcitation Coding + AOT_TTSI = 12, ///< N Text-To-Speech Interface -AOT_MAINSYNTH, ///< N Main Synthesis -AOT_WAVESYNTH, ///< N Wavetable Synthesis -AOT_MIDI, ///< N General MIDI -AOT_SAFX, ///< N Algorithmic Synthesis and Audio Effects -AOT_ER_AAC_LC, ///< N Error Resilient Low Complexity +AOT_MAINSYNTH= 13, ///< N Main Synthesis +AOT_WAVESYNTH= 14, ///< N Wavetable Synthesis +AOT_MIDI = 15, ///< N General MIDI +AOT_SAFX = 16, ///< N Algorithmic Synthesis and Audio Effects +AOT_ER_AAC_LC= 17, ///< N Error Resilient Low Complexity + AOT_ER_AAC_LTP = 19, ///< N Error Resilient Long Term Prediction -AOT_ER_AAC_SCALABLE, ///< N Error Resilient Scalable -AOT_ER_TWINVQ, ///< N Error Resilient Twin Vector Quantizer -AOT_ER_BSAC, ///< N Error Resilient Bit-Sliced Arithmetic Coding -AOT_ER_AAC_LD, ///< N Error Resilient Low Delay -AOT_ER_CELP, ///< N Error Resilient Code Excited Linear Prediction -AOT_ER_HVXC, ///< N Error Resilient Harmonic Vector eXcitation Coding -AOT_ER_HILN, ///< N Error Resilient Harmonic and Individual Lines plus Noise -AOT_ER_PARAM, ///< N Error Resilient Parametric -AOT_SSC, ///< N SinuSoidal Coding -AOT_PS,///< N Parametric Stereo -AOT_SURROUND, ///< N MPEG Surround -AOT_ESCAPE,///< Y Escape Value -AOT_L1,///< Y Layer 1 -AOT_L2,///< Y Layer 2 -AOT_L3,///< Y Layer 3 -AOT_DST, ///< N Direct Stream Transfer -AOT_ALS, ///< Y Audio LosslesS -AOT_SLS, ///< N Scalable LosslesS -AOT_SLS_NON_CORE, ///< N Scalable LosslesS (non core) -AOT_ER_AAC_ELD,///< N Error Resilient Enhanced Low Delay -AOT_SMR_SIMPLE,
Re: [FFmpeg-devel] [PATCH 3/4] aac: define a new profile for USAC
On 05/06/2024 07:33, Andreas Rheinhardt wrote: Lynne via ffmpeg-devel: This allows users to determine whether a stream is USAC or not. --- libavcodec/aac/aacdec_usac.c | 4 libavcodec/avcodec.h | 1 + libavcodec/defs.h| 1 + libavcodec/profiles.c| 1 + libavcodec/profiles.h| 1 + 5 files changed, 8 insertions(+) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 7b36b49d63..5c3bb8d4ac 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -494,6 +494,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, } } +ac->avctx->profile = AV_PROFILE_AAC_USAC; + ret = ff_aac_usac_reset_state(ac, oc); if (ret < 0) return ret; @@ -1533,6 +1535,8 @@ int ff_aac_usac_decode_frame(AVCodecContext *avctx, AACDecContext *ac, ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags, ac->oc[1].status, 0); +ac->avctx->profile = AV_PROFILE_AAC_USAC; + indep_flag = get_bits1(gb); nb_ch_el = 0; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2da63c87ea..257e04fe2d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1652,6 +1652,7 @@ typedef struct AVCodecContext { #define FF_PROFILE_AAC_HE_V2 28 #define FF_PROFILE_AAC_LD 22 #define FF_PROFILE_AAC_ELD 38 +#define FF_PROFILE_AAC_USAC 41 Don't add new deprecated defines. Didn't notice. Removed locally. 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] aacdec: increase MAX_ELEM_ID to 64
In USAC, we set the max to 64. --- libavcodec/aac.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 9508760fa6..fc6d1361b2 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -31,7 +31,7 @@ #define AVCODEC_AAC_H #define MAX_CHANNELS 64 -#define MAX_ELEM_ID 16 +#define MAX_ELEM_ID 64 #define TNS_MAX_ORDER 20 #define MAX_LTP_LONG_SFB 40 -- 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] aacdec_usac: correctly set and use the layout map
--- libavcodec/aac/aacdec_usac.c | 105 +-- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 04dd5facff..561734f930 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -268,17 +268,25 @@ int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc) /* Initialize state */ for (int i = 0; i < usac->nb_elems; i++) { AACUsacElemConfig *e = &usac->elems[i]; -if (e->type != ID_USAC_SCE && e->type != ID_USAC_CPE) +if (e->type == ID_USAC_EXT) continue; -if (e->type == ID_USAC_SCE) { +switch (e->type) { +case ID_USAC_SCE: ch = 1; type = TYPE_SCE; id = elem_id[0]++; -} else { +break; +case ID_USAC_CPE: ch = 2; type = TYPE_CPE; id = elem_id[1]++; +break; +case ID_USAC_LFE: +ch = 1; +type = TYPE_LFE; +id = elem_id[2]++; +break; } che = ff_aac_get_che(ac, type, id); @@ -318,7 +326,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, AACUSACConfig *usac = &oc->usac; int elem_id[3 /* SCE, CPE, LFE */]; -uint8_t layout_map[MAX_ELEM_ID*4][3]; +int map_pos_set = 0; +uint8_t layout_map[MAX_ELEM_ID*4][3] = { 0 }; memset(usac, 0, sizeof(*usac)); @@ -391,6 +400,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, /* Fill in the number of expected channels */ for (int i = 0; i < nb_elements; i++) nb_channels += layout_map[i][0] == TYPE_CPE ? 2 : 1; + +map_pos_set = 1; } /* UsacDecoderConfig */ @@ -404,12 +415,12 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, } for (int i = 0; i < usac->nb_elems; i++) { +int map_count = elem_id[0] + elem_id[1] + elem_id[2]; AACUsacElemConfig *e = &usac->elems[i]; memset(e, 0, sizeof(*e)); e->type = get_bits(gb, 2); /* usacElementType */ -if (e->type != ID_USAC_EXT && -(elem_id[0] + elem_id[1] + elem_id[2] + 1) > nb_channels) { +if (e->type != ID_USAC_EXT && (map_count + 1) > nb_channels) { av_log(ac->avctx, AV_LOG_ERROR, "Too many channels for the channel " "configuration\n"); usac->nb_elems = 0; @@ -425,30 +436,31 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, decode_usac_element_core(e, gb, sbr_ratio); if (e->sbr.ratio > 0) decode_usac_sbr_data(e, gb); -layout_map[i][0] = TYPE_SCE; -layout_map[i][1] = i; -layout_map[i][2] = AAC_CHANNEL_FRONT; -elem_id[0]++; +layout_map[map_count][0] = TYPE_SCE; +layout_map[map_count][1] = elem_id[0]++; +if (!map_pos_set) +layout_map[map_count][2] = AAC_CHANNEL_FRONT; break; case ID_USAC_CPE: /* UsacChannelPairElementConf */ /* UsacCoreConfig */ decode_usac_element_core(e, gb, sbr_ratio); decode_usac_element_pair(e, gb); -layout_map[i][0] = TYPE_CPE; -layout_map[i][1] = i; -layout_map[i][2] = AAC_CHANNEL_FRONT; -elem_id[1]++; +layout_map[map_count][0] = TYPE_CPE; +layout_map[map_count][1] = elem_id[1]++; +if (!map_pos_set) +layout_map[map_count][2] = AAC_CHANNEL_FRONT; break; case ID_USAC_LFE: /* LFE */ /* LFE has no need for any configuration */ e->tw_mdct = 0; e->noise_fill = 0; -layout_map[i][0] = TYPE_LFE; -layout_map[i][1] = i; -layout_map[i][2] = AAC_CHANNEL_LFE; -elem_id[2]++; +layout_map[map_count][0] = TYPE_LFE; +layout_map[map_count][1] = elem_id[2]++; +if (!map_pos_set) +layout_map[map_count][2] = AAC_CHANNEL_LFE; + break; case ID_USAC_EXT: /* EXT */ ret = decode_usac_extension(ac, e, gb); @@ -458,7 +470,8 @@ int ff_aac_usac_config_decode(AACDecContext *ac, AVCodecContext *avctx, }; } -ret = ff_aac_output_configure(ac, layout_map, elem_id[0] + elem_id[1] + elem_id[2], OC_GLOBAL_HDR, 0); +ret = ff_aac_output_configure(ac, layout_map, elem_id[0] + elem_id[1] + elem_id[2], + OC_GLOBAL_HDR, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Unable to parse channel config!\n"); usac->nb_elems = 0; @@ -1531,9 +1544,11 @@ static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e, int ff_aac_usac_decode_frame(AVCodecContext *avctx
[FFmpeg-devel] [PATCH 1/4] aacdec_usac: respect tns_on_lr flag
This was left out, and due to av_unused, forgotten about. --- libavcodec/aac/aacdec.h | 1 + libavcodec/aac/aacdec_usac.c | 16 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index ee21a94007..f0a33e7ac3 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -230,6 +230,7 @@ typedef struct SingleChannelElement { typedef struct AACUsacStereo { uint8_t common_window; uint8_t common_tw; +uint8_t tns_on_lr; ///< Apply TNS before M/S and stereo prediction uint8_t ms_mask_mode; uint8_t config_idx; diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 561734f930..3b4e980df4 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -876,14 +876,14 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, return AVERROR_PATCHWELCOME; } +us->tns_on_lr = 0; sce1->tns.present = sce2->tns.present = 0; if (tns_active) { -av_unused int tns_on_lr; int common_tns = 0; if (us->common_window) common_tns = get_bits1(gb); -tns_on_lr = get_bits1(gb); +us->tns_on_lr = get_bits1(gb); if (common_tns) { ret = ff_aac_decode_tns(ac, &sce1->tns, gb, ics1); if (ret < 0) @@ -1214,6 +1214,14 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, } if (nb_channels > 1 && us->common_window) { +for (int ch = 0; ch < nb_channels; ch++) { +SingleChannelElement *sce = &cpe->ch[ch]; + +/* Apply TNS, if the tns_on_lr bit is not set. */ +if (sce->tns.present && !us->tns_on_lr) +ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1); +} + if (us->ms_mask_mode == 3) { const float *filt; complex_stereo_downmix_cur(ac, cpe, us->dmix_re); @@ -1248,8 +1256,8 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac, for (int ch = 0; ch < nb_channels; ch++) { SingleChannelElement *sce = &cpe->ch[ch]; -/* Apply TNS */ -if (sce->tns.present) +/* Apply TNS, if it hasn't been applied yet. */ +if (sce->tns.present && ((nb_channels == 1) || (us->tns_on_lr))) ac->dsp.apply_tns(sce->coeffs, &sce->tns, &sce->ics, 1); ac->oc[1].m4ac.frame_length_short ? ac->dsp.imdct_and_windowing_768(ac, sce) : -- 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/4] aacdec_usac: do not continue parsing bitstream on core_mode == 1
Although LPD is not functional yet, the bitstream ends at that point. --- libavcodec/aac/aacdec_usac.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 3b4e980df4..9b28a9e90b 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -1301,6 +1301,7 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, ret = ff_aac_ldp_parse_channel_stream(ac, usac, ue, gb); if (ret < 0) return ret; +continue; } if ((nb_channels == 1) || -- 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 3/4] aacdec_usac: decouple TNS active from TNS data present flag
The issue was that in case of common TNS parameters, TNS was entirely skipped, as tns.present was set to 0. --- libavcodec/aac/aacdec.h | 1 + libavcodec/aac/aacdec_usac.c | 25 +++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h index f0a33e7ac3..a2ef4a82e8 100644 --- a/libavcodec/aac/aacdec.h +++ b/libavcodec/aac/aacdec.h @@ -125,6 +125,7 @@ typedef struct LongTermPrediction { typedef struct AACUsacElemData { uint8_t core_mode; uint8_t scale_factor_grouping; +uint8_t tns_data_present; /* Timewarping ratio */ #define NUM_TW_NODES 16 diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 9b28a9e90b..97655787ee 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -877,7 +877,7 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, } us->tns_on_lr = 0; -sce1->tns.present = sce2->tns.present = 0; +ue1->tns_data_present = ue2->tns_data_present = 0; if (tns_active) { int common_tns = 0; if (us->common_window) @@ -889,15 +889,17 @@ static int decode_usac_stereo_info(AACDecContext *ac, AACUSACConfig *usac, if (ret < 0) return ret; memcpy(&sce2->tns, &sce1->tns, sizeof(sce1->tns)); -sce2->tns.present = 0; -sce1->tns.present = 0; +sce2->tns.present = 1; +sce1->tns.present = 1; +ue1->tns_data_present = 0; +ue2->tns_data_present = 0; } else { if (get_bits1(gb)) { -sce2->tns.present = 1; -sce1->tns.present = 1; +ue1->tns_data_present = 1; +ue2->tns_data_present = 1; } else { -sce2->tns.present = get_bits1(gb); -sce1->tns.present = !sce2->tns.present; +ue2->tns_data_present = get_bits1(gb); +ue1->tns_data_present = !ue2->tns_data_present; } } } @@ -1277,12 +1279,14 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, uint8_t global_gain; us->common_window = 0; -che->ch[0].tns.present = che->ch[1].tns.present = 0; for (int ch = 0; ch < nb_channels; ch++) { SingleChannelElement *sce = &che->ch[ch]; AACUsacElemData *ue = &sce->ue; +sce->tns.present = 0; +ue->tns_data_present = 0; + ue->core_mode = get_bits1(gb); } @@ -1306,7 +1310,7 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, if ((nb_channels == 1) || (che->ch[0].ue.core_mode != che->ch[1].ue.core_mode)) -sce->tns.present = get_bits1(gb); +ue->tns_data_present = get_bits1(gb); /* fd_channel_stream */ global_gain = get_bits(gb, 8); @@ -1351,7 +1355,8 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac, ac->dsp.dequant_scalefactors(sce); -if (sce->tns.present) { +if (ue->tns_data_present) { +sce->tns.present = 1; ret = ff_aac_decode_tns(ac, &sce->tns, gb, ics); if (ret < 0) return ret; -- 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 4/4] aacdec_usac: skip coeff decoding if the number to be decoded is 0
Yet another thing not mentioned in the spec. --- libavcodec/aac/aacdec_usac.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/aac/aacdec_usac.c b/libavcodec/aac/aacdec_usac.c index 97655787ee..5dd489a43b 100644 --- a/libavcodec/aac/aacdec_usac.c +++ b/libavcodec/aac/aacdec_usac.c @@ -572,9 +572,15 @@ static int decode_spectrum_and_dequant_ac(AACDecContext *s, float coef[1024], int gb_count; GetBitContext gb2; -ff_aac_ac_init(&ac, gb); c = ff_aac_ac_map_process(state, reset, N); +if (!len) { +ff_aac_ac_finish(state, 0, N); +return 0; +} + +ff_aac_ac_init(&ac, gb); + /* Backup reader for rolling back by 14 bits at the end */ gb2 = *gb; gb_count = get_bits_count(&gb2); -- 2.43.0.381.gb435a96ce8 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v13 15/15] avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctx
On 03/06/2024 11:19, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu This patch is to make FFHWBaseEncodeContext a standalone component and avoid getting FFHWBaseEncodeContext from avctx->priv_data. This patch also removes some unnecessary AVCodecContext arguments. For receive_packet call, a small wrapper is introduced. Signed-off-by: Tong Wu --- libavcodec/d3d12va_encode.c | 17 +--- libavcodec/d3d12va_encode.h | 2 + libavcodec/d3d12va_encode_hevc.c | 2 +- libavcodec/hw_base_encode.c | 71 ++-- libavcodec/hw_base_encode.h | 17 libavcodec/vaapi_encode.c| 16 --- libavcodec/vaapi_encode.h| 2 + libavcodec/vaapi_encode_av1.c| 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 2 +- libavcodec/vaapi_encode_mpeg2.c | 2 +- libavcodec/vaapi_encode_vp8.c| 2 +- libavcodec/vaapi_encode_vp9.c| 2 +- 14 files changed, 76 insertions(+), 65 deletions(-) diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c index 0fbf8eb07c..9f7a42911e 100644 --- a/libavcodec/d3d12va_encode.c +++ b/libavcodec/d3d12va_encode.c @@ -676,6 +676,7 @@ end: static int d3d12va_encode_output(AVCodecContext *avctx, const FFHWBaseEncodePicture *base_pic, AVPacket *pkt) { +FFHWBaseEncodeContext *base_ctx = avctx->priv_data; D3D12VAEncodePicture *pic = (D3D12VAEncodePicture *)base_pic; AVPacket *pkt_ptr = pkt; int err; @@ -691,7 +692,8 @@ static int d3d12va_encode_output(AVCodecContext *avctx, av_log(avctx, AV_LOG_DEBUG, "Output read for pic %"PRId64"/%"PRId64".\n", base_pic->display_order, base_pic->encode_order); -ff_hw_base_encode_set_output_property(avctx, (FFHWBaseEncodePicture *)base_pic, pkt_ptr, 0); +ff_hw_base_encode_set_output_property(base_ctx, avctx, (FFHWBaseEncodePicture *)base_pic, + pkt_ptr, 0); return 0; } @@ -1119,7 +1121,7 @@ static int d3d12va_encode_init_gop_structure(AVCodecContext *avctx) "replacing them with B-frames.\n"); } -err = ff_hw_base_init_gop_structure(avctx, ref_l0, ref_l1, ctx->codec->flags, 0); +err = ff_hw_base_init_gop_structure(base_ctx, avctx, ref_l0, ref_l1, ctx->codec->flags, 0); if (err < 0) return err; @@ -1351,7 +1353,7 @@ static int d3d12va_encode_create_recon_frames(AVCodecContext *avctx) enum AVPixelFormat recon_format; int err; -err = ff_hw_base_get_recon_format(avctx, NULL, &recon_format); +err = ff_hw_base_get_recon_format(base_ctx, NULL, &recon_format); if (err < 0) return err; @@ -1390,6 +1392,11 @@ static const FFHWEncodePictureOperation d3d12va_type = { .free = &d3d12va_encode_free, }; +int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt) +{ +return ff_hw_base_encode_receive_packet(avctx->priv_data, avctx, pkt); +} + int ff_d3d12va_encode_init(AVCodecContext *avctx) { FFHWBaseEncodeContext *base_ctx = avctx->priv_data; @@ -1398,7 +1405,7 @@ int ff_d3d12va_encode_init(AVCodecContext *avctx) int err; HRESULT hr; -err = ff_hw_base_encode_init(avctx); +err = ff_hw_base_encode_init(avctx, base_ctx); if (err < 0) goto fail; @@ -1552,7 +1559,7 @@ int ff_d3d12va_encode_close(AVCodecContext *avctx) D3D12_OBJECT_RELEASE(ctx->video_device3); D3D12_OBJECT_RELEASE(ctx->device3); -ff_hw_base_encode_close(avctx); +ff_hw_base_encode_close(base_ctx); return 0; } diff --git a/libavcodec/d3d12va_encode.h b/libavcodec/d3d12va_encode.h index f355261f66..1a0abc5bd0 100644 --- a/libavcodec/d3d12va_encode.h +++ b/libavcodec/d3d12va_encode.h @@ -313,6 +313,8 @@ typedef struct D3D12VAEncodeType { char *data, size_t *data_len); } D3D12VAEncodeType; +int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); + int ff_d3d12va_encode_init(AVCodecContext *avctx); int ff_d3d12va_encode_close(AVCodecContext *avctx); diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c index 24823b3c56..4a12ddd0dc 100644 --- a/libavcodec/d3d12va_encode_hevc.c +++ b/libavcodec/d3d12va_encode_hevc.c @@ -990,7 +990,7 @@ const FFCodec ff_hevc_d3d12va_encoder = { .p.id = AV_CODEC_ID_HEVC, .priv_data_size = sizeof(D3D12VAEncodeHEVCContext), .init = &d3d12va_encode_hevc_init, -FF_CODEC_RECEIVE_PACKET_CB(&ff_hw_base_encode_receive_packet), +FF_CODEC_RECEIVE_PACKET_CB(&ff_d3d12va_encode_receive_packet), .close = &d3d12va_encode_hevc_close, .p.priv_class = &d3d12va_encode_hevc_class, .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | diff --git a/libavcodec/hw_base_encode.c b/libavco
Re: [FFmpeg-devel] [PATCH v13 15/15] avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctx
On 06/06/2024 08:46, Wu, Tong1 wrote: From: ffmpeg-devel On Behalf Of Lynne via ffmpeg-devel Sent: Thursday, June 6, 2024 2:11 PM To: ffmpeg-devel@ffmpeg.org Cc: Lynne Subject: Re: [FFmpeg-devel] [PATCH v13 15/15] avcodec/hw_base_encode: avoid getting FFHWBaseEncodeContext from avctx On 03/06/2024 11:19, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu This patch is to make FFHWBaseEncodeContext a standalone component and avoid getting FFHWBaseEncodeContext from avctx->priv_data. This patch also removes some unnecessary AVCodecContext arguments. For receive_packet call, a small wrapper is introduced. Signed-off-by: Tong Wu --- libavcodec/d3d12va_encode.c | 17 +--- libavcodec/d3d12va_encode.h | 2 + libavcodec/d3d12va_encode_hevc.c | 2 +- libavcodec/hw_base_encode.c | 71 ++-- libavcodec/hw_base_encode.h | 17 libavcodec/vaapi_encode.c| 16 --- libavcodec/vaapi_encode.h| 2 + libavcodec/vaapi_encode_av1.c| 2 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 2 +- libavcodec/vaapi_encode_mpeg2.c | 2 +- libavcodec/vaapi_encode_vp8.c| 2 +- libavcodec/vaapi_encode_vp9.c| 2 +- 14 files changed, 76 insertions(+), 65 deletions(-) diff --git a/libavcodec/d3d12va_encode.c b/libavcodec/d3d12va_encode.c index 0fbf8eb07c..9f7a42911e 100644 --- a/libavcodec/d3d12va_encode.c +++ b/libavcodec/d3d12va_encode.c @@ -676,6 +676,7 @@ end: static int d3d12va_encode_output(AVCodecContext *avctx, const FFHWBaseEncodePicture *base_pic, AVPacket *pkt) { +FFHWBaseEncodeContext *base_ctx = avctx->priv_data; D3D12VAEncodePicture *pic = (D3D12VAEncodePicture *)base_pic; AVPacket *pkt_ptr = pkt; int err; @@ -691,7 +692,8 @@ static int d3d12va_encode_output(AVCodecContext *avctx, av_log(avctx, AV_LOG_DEBUG, "Output read for pic %"PRId64"/%"PRId64".\n", base_pic->display_order, base_pic->encode_order); -ff_hw_base_encode_set_output_property(avctx, (FFHWBaseEncodePicture *)base_pic, pkt_ptr, 0); +ff_hw_base_encode_set_output_property(base_ctx, avctx, (FFHWBaseEncodePicture *)base_pic, + pkt_ptr, 0); return 0; } @@ -1119,7 +1121,7 @@ static int d3d12va_encode_init_gop_structure(AVCodecContext *avctx) "replacing them with B-frames.\n"); } -err = ff_hw_base_init_gop_structure(avctx, ref_l0, ref_l1, ctx->codec- flags, 0); +err = ff_hw_base_init_gop_structure(base_ctx, avctx, ref_l0, ref_l1, ctx- codec->flags, 0); if (err < 0) return err; @@ -1351,7 +1353,7 @@ static int d3d12va_encode_create_recon_frames(AVCodecContext *avctx) enum AVPixelFormat recon_format; int err; -err = ff_hw_base_get_recon_format(avctx, NULL, &recon_format); +err = ff_hw_base_get_recon_format(base_ctx, NULL, &recon_format); if (err < 0) return err; @@ -1390,6 +1392,11 @@ static const FFHWEncodePictureOperation d3d12va_type = { .free = &d3d12va_encode_free, }; +int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt) +{ +return ff_hw_base_encode_receive_packet(avctx->priv_data, avctx, pkt); +} + int ff_d3d12va_encode_init(AVCodecContext *avctx) { FFHWBaseEncodeContext *base_ctx = avctx->priv_data; @@ -1398,7 +1405,7 @@ int ff_d3d12va_encode_init(AVCodecContext *avctx) int err; HRESULT hr; -err = ff_hw_base_encode_init(avctx); +err = ff_hw_base_encode_init(avctx, base_ctx); if (err < 0) goto fail; @@ -1552,7 +1559,7 @@ int ff_d3d12va_encode_close(AVCodecContext *avctx) D3D12_OBJECT_RELEASE(ctx->video_device3); D3D12_OBJECT_RELEASE(ctx->device3); -ff_hw_base_encode_close(avctx); +ff_hw_base_encode_close(base_ctx); return 0; } diff --git a/libavcodec/d3d12va_encode.h b/libavcodec/d3d12va_encode.h index f355261f66..1a0abc5bd0 100644 --- a/libavcodec/d3d12va_encode.h +++ b/libavcodec/d3d12va_encode.h @@ -313,6 +313,8 @@ typedef struct D3D12VAEncodeType { char *data, size_t *data_len); } D3D12VAEncodeType; +int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt); + int ff_d3d12va_encode_init(AVCodecContext *avctx); int ff_d3d12va_encode_close(AVCodecContext *avctx); diff --git a/libavcodec/d3d12va_encode_hevc.c b/libavcodec/d3d12va_encode_hevc.c index 24823b3c56..4a12ddd0dc 100644 --- a/libavcodec/d3d12va_encode_hevc.c +++ b/libavcodec/d3d12va_encode_hevc.c @@ -990,7 +990,7 @@ const FFCodec ff_hevc_d3d12va_encoder = { .p.id = AV_CODEC_ID_HEVC, .priv_data_size = sizeof(D3D12VAEncodeHEVCCo
Re: [FFmpeg-devel] [PATCH v13 06/15] avcodec/vaapi_encode: move the dpb logic from VAAPI to base layer
On 03/06/2024 11:18, tong1.wu-at-intel@ffmpeg.org wrote: From: Tong Wu Move receive_packet function to base. This requires adding *alloc, *issue, *output, *free as hardware callbacks. HWBaseEncodePicture is introduced as the base layer structure. The related parameters in VAAPIEncodeContext are also extracted to HWBaseEncodeContext. Then DPB management logic can be fully extracted to base layer as-is. Signed-off-by: Tong Wu --- libavcodec/Makefile | 2 +- libavcodec/hw_base_encode.c | 594 libavcodec/hw_base_encode.h | 124 + libavcodec/vaapi_encode.c | 793 +--- libavcodec/vaapi_encode.h | 102 +--- libavcodec/vaapi_encode_av1.c | 35 +- libavcodec/vaapi_encode_h264.c | 84 ++-- libavcodec/vaapi_encode_h265.c | 53 ++- libavcodec/vaapi_encode_mjpeg.c | 13 +- libavcodec/vaapi_encode_mpeg2.c | 33 +- libavcodec/vaapi_encode_vp8.c | 18 +- libavcodec/vaapi_encode_vp9.c | 24 +- 12 files changed, 985 insertions(+), 890 deletions(-) create mode 100644 libavcodec/hw_base_encode.c This patch doesn't apply, error: sha1 information is lacking or useless (libavcodec/hw_base_encode.c). error: could not build fake ancestor Could you resent the patchset or link me a repo so I can work with it? 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".