summaryrefslogtreecommitdiff
path: root/libavcodec
Commit message (Collapse)AuthorAge
* avcodec/libvpxenc: add a way to set VP9E_SET_SVC_REF_FRAME_CONFIGWonkap Jang2021-01-14
| | | | | | In order to fine-control referencing schemes in VP9 encoding, there is a need to use VP9E_SET_SVC_REF_FRAME_CONFIG method. This commit provides a way to use the API through frame metadata.
* fft: remove 16-bit FFT and MDCT codeLynne2021-01-14
| | | | | | No longer used by anything. Unfortunately the old FFT_FLOAT/FFT_FIXED_32 is left as-is. It's simply too much work for code meant to be all removed anyway.
* ac3enc_fixed: drop unnecessary fixed-point DSP codeLynne2021-01-14
|
* ac3enc: halve the MDCT window size by using vector_fmul_reverseLynne2021-01-14
| | | | | This brings the encoder in-line with the rest of ours and saves on a bit of memory.
* ac3enc: do not clip coefficients after transformsLynne2021-01-14
| | | | | | | In either encoder, its impossible for the coefficients to go past 25 bits right after the MDCT. Our MDCT is numerically stable. For the floating point encoder, in case a NaN is contained, lrintf() will raise a floating point exception during the conversion.
* ac3enc_fixed: convert to 32-bit sample formatLynne2021-01-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The AC3 encoder used to be a separate library called "Aften", which got merged into libavcodec (literally, SVN commits and all). The merge preserved as much features from the library as possible. The code had two versions - a fixed point version and a floating point version. FFmpeg had floating point DSP code used by other codecs, the AC3 decoder including, so the floating-point DSP was simply replaced with FFmpeg's own functions. However, FFmpeg had no fixed-point audio code at that point. So the encoder brought along its own fixed-point DSP functions, including a fixed-point MDCT. The fixed-point MDCT itself is trivially just a float MDCT with a different type and each multiply being a fixed-point multiply. So over time, it got refactored, and the FFT used for all other codecs was templated. Due to design decisions at the time, the fixed-point version of the encoder operates at 16-bits of precision. Although convenient, this, even at the time, was inadequate and inefficient. The encoder is noisy, does not produce output comparable to the float encoder, and even rings at higher frequencies due to the badly approximated winow function. Enter MIPS (owned by Imagination Technologies at the time). They wanted quick fixed-point decoding on their FPUless cores. So they contributed patches to template the AC3 decoder so it had both a fixed-point and a floating-point version. They also did the same for the AAC decoder. They however, used 32-bit samples. Not 16-bits. And we did not have 32-bit fixed-point DSP functions, including an MDCT. But instead of templating our MDCT to output 3 versions (float, 32-bit fixed and 16-bit fixed), they simply copy-pasted their own MDCT into ours, and completely ifdeffed our own MDCT code out if a 32-bit fixed point MDCT was selected. This is also the status quo nowadays - 2 separate MDCTs, one which produces floating point and 16-bit fixed point versions, and one sort-of integrated which produces 32-bit MDCT. MIPS weren't all that interested in encoding, so they left the encoder as-is, and they didn't care much about the ifdeffery, mess or quality - it's not their problem. So the MDCT/FFT code has always been a thorn in anyone looking to clean up code's eye. Backstory over. Internally AC3 operates on 25-bit fixed-point coefficients. So for the floating point version, the encoder simply runs the float MDCT, and converts the resulting coefficients to 25-bit fixed-point, as AC3 is inherently a fixed-point codec. For the fixed-point version, the input is 16-bit samples, so to maximize precision the frame samples are analyzed and the highest set bit is detected via ac3_max_msb_abs_int16(), and the coefficients are then scaled up via ac3_lshift_int16(), so the input for the FFT is always at least 14 bits, computed in normalize_samples(). After FFT, the coefficients are scaled up to 25 bits. This patch simply changes the encoder to accept 32-bit samples, reusing the already well-optimized 32-bit MDCT code, allowing us to clean up and drop a large part of a very messy code of ours, as well as prepare for the future lavu/tx conversion. The coefficients are simply scaled down to 25 bits during windowing, skipping 2 separate scalings, as the hacks to extend precision are simply no longer necessary. There's no point in running the MDCT always at 32 bits when you're going to drop 6 bits off anyway, the headroom is plenty, and the MDCT rounds properly. This also makes the encoder even slightly more accurate over the float version, as there's no coefficient conversion step necessary. SIZE SAVINGS: ARM32: HARDCODED TABLES: BASE - 10709590 DROP DSP - 10702872 - diff: -6.56KiB DROP MDCT - 10667932 - diff: -34.12KiB - both: -40.68KiB DROP FFT - 10336652 - diff: -323.52KiB - all: -364.20KiB SOFTCODED TABLES: BASE - 9685096 DROP DSP - 9678378 - diff: -6.56KiB DROP MDCT - 9643466 - diff: -34.09KiB - both: -40.65KiB DROP FFT - 9573918 - diff: -67.92KiB - all: -108.57KiB ARM64: HARDCODED TABLES: BASE - 14641112 DROP DSP - 14633806 - diff: -7.13KiB DROP MDCT - 14604812 - diff: -28.31KiB - both: -35.45KiB DROP FFT - 14286826 - diff: -310.53KiB - all: -345.98KiB SOFTCODED TABLES: BASE - 13636238 DROP DSP - 13628932 - diff: -7.13KiB DROP MDCT - 13599866 - diff: -28.38KiB - both: -35.52KiB DROP FFT - 13542080 - diff: -56.43KiB - all: -91.95KiB x86: HARDCODED TABLES: BASE - 12367336 DROP DSP - 12354698 - diff: -12.34KiB DROP MDCT - 12331024 - diff: -23.12KiB - both: -35.46KiB DROP FFT - 12029788 - diff: -294.18KiB - all: -329.64KiB SOFTCODED TABLES: BASE - 11358094 DROP DSP - 11345456 - diff: -12.34KiB DROP MDCT - 11321742 - diff: -23.16KiB - both: -35.50KiB DROP FFT - 11276946 - diff: -43.75KiB - all: -79.25KiB PERFORMANCE (10min random s32le): ARM32 - before - 39.9x - 0m15.046s ARM32 - after - 28.2x - 0m21.525s Speed: -30% ARM64 - before - 36.1x - 0m16.637s ARM64 - after - 36.0x - 0m16.727s Speed: -0.5% x86 - before - 184x - 0m3.277s x86 - after - 190x - 0m3.187s Speed: +3%
* avcodec/cbs_h2645: Move zero_byte check to its own functionNuo Mi2021-01-11
| | | | Signed-off-by: Mark Thompson <sw@jkqxz.net>
* avcodec/cbs_h265: fix undef SEI_TYPE_XNuo Mi2021-01-11
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec: add vvc codec id and profilesNuo Mi2021-01-11
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: constify decompose_unit_typesJames Almer2021-01-10
| | | | | | | CBS doesn't change its contents in any way whatsoever internally, and most users already set it to a const array. Signed-off-by: James Almer <jamrial@gmail.com>
* sbc: do not set sample format in parserArnaud Vrac2021-01-09
| | | | | | | | | | | | Commit bdd31feec934 changed the SBC decoder to only set the output sample format on init, instead of setting it explicitly on each frame, which is correct. But the SBC parser overrides the sample format to S16, which triggers a crash when combining the parser and the decoder. Fix the issue by not setting the sample format anymore in the parser, which is wrong. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/nvenc: fix timestamp offset ticks logicTimo Rothenpieler2021-01-09
|
* avcodec/ac3dec: Make decoders init-threadsafeAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3dec: Check operations that can failAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3enc: Factor common end of float/fixed encode_frame outAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3enc_template: Perform compile-time checks at compile-timeAndreas Rheinhardt2021-01-09
| | | | | | | | | Runtime checks for whether the encoder is fixed-point or not are unnecessary here as this is a template; furthermore, there is no fixed-point EAC-3 encoder, so some checks for whether one is in EAC-3 mode can be omitted when doing fixed-point encoding. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/[e]ac3enc: Don't invade CONFIG_ namespaceAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/ac3enc: Set function pointers earlierAndreas Rheinhardt2021-01-09
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/[e]ac3enc: Make encoders init-threadsafe, fix raceAndreas Rheinhardt2021-01-09
| | | | | | | | | | | ff_eac3_exponent_init() set values twice when initializing a static table; ergo the initialization code must not run concurrently with a running EAC-3 encoder. Yet this code is executed every time an EAC-3 encoder is initialized. So use ff_thread_once() for this and also for a similar initialization performed for all AC-3 encoders to make them all init-threadsafe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/wmaprodec: Check packet sizeMichael Niedermayer2021-01-08
| | | | | | | | Fixes: left shift of negative value -25824 Fixes: 27754/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XMA2_fuzzer-5760255962906624 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/rasc: Check frame before clearingMichael Niedermayer2021-01-08
| | | | | | | | Fixes: null pointer dereference Fixes: 27737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5769028685266944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86Andreas Rheinhardt2021-01-08
| | | | | | | | Also do it for FFT_FLOAT only, as this is the only combination for which it can be set. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/wavpack: Deduplicate exp and log tablesAndreas Rheinhardt2021-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/vp3data: Deduplicate coeff_tablesAndreas Rheinhardt2021-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/twinvq, metasound_data: Deduplicate lsp tablesAndreas Rheinhardt2021-01-08
| | | | | | Saves about 24KB. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/metasound: Deduplicate dataAndreas Rheinhardt2021-01-08
| | | | | | Saves about 13KB; also reduces the amount of relocations. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/g723_1: Move tables to their only userAndreas Rheinhardt2021-01-08
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/g723_1: Deduplicate arraysAndreas Rheinhardt2021-01-08
| | | | | | Saves about 17KB. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/libopusenc: Fix for header pre-skip valueArthur Taylor2021-01-07
| | | | | | | | | The Opus header initial padding preskip amount is always to be expressed relative to 48kHz. However, the encoder delay returned from querying libopus is relative to the encoding samplerate. Multiply by the samplerate conversion factor to correct. Signed-off-by: Arthur Taylor <art@ified.ca>
* avcodec/alsdec: Fix integer overflow with quant_cofMichael Niedermayer2021-01-05
| | | | | | | | Fixes: signed integer overflow: -210824 * 16384 cannot be represented in type 'int' Fixes: 28670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5682310846480384 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/av1dec: add an option to select an operating pointJames Almer2021-01-04
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs_av1: add an option to select an operating pointJames Almer2021-01-04
| | | | | | | | | This implements the function drop_obu() as defined in Setion 6.2.1 from the spec. In a reading only scenario, units that belong to an operating point the caller doesn't want should not be parsed. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: allow cbs_read_fragment_content() to skip decomposition of unitsJames Almer2021-01-04
| | | | | | | | | | The caller may not need all units in a fragment in reading only scenarios. They could in fact alter global state stored in the private CodedBitstreamType fields in an undesirable way. With this change, unit decomposition can be skipped based on parsed values within the unit. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/cbs: add an AVClass to CodedBitstreamType for option handlingJames Almer2021-01-04
| | | | | | So unit parsing may be configured with caller set options. Signed-off-by: James Almer <jamrial@gmail.com>
* avcodec/libkvazaar: Set default ratecontrol algorithm for libkvazaarJoose Sainio2021-01-04
| | | | | | | | The standalone version of Kvazaar sets a default ratecontrol algorithm when bitrate is set. Mirror this behaviour. Signed-off-by: Joose Sainio <joose.sainio@tuni.fi> Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* avcodec/hevcdec: fix stat_coeff save/load for ↵Xu Guangxin2021-01-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | persistent_rice_adaptation_enabled_flag It's required by the 9.3.1 TableStatCoeff* section. Following clips have this feature: WPP_HIGH_TP_444_8BIT_RExt_Apple_2.bit Bitdepth_A_RExt_Sony_1.bin Bitdepth_B_RExt_Sony_1.bin EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_10BIT_RExt_Sony_1.bit EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_12BIT_RExt_Sony_1.bit EXTPREC_HIGHTHROUGHPUT_444_16_INTRA_8BIT_RExt_Sony_1.bit EXTPREC_MAIN_444_16_INTRA_10BIT_RExt_Sony_1.bit EXTPREC_MAIN_444_16_INTRA_12BIT_RExt_Sony_1.bit EXTPREC_MAIN_444_16_INTRA_8BIT_RExt_Sony_1.bit WPP_AND_TILE_10Bit422Test_HIGH_TP_444_10BIT_RExt_Apple_2.bit WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_0_HIGH_TP_444_14BIT_RExt_Apple_2.bit WPP_AND_TILE_AND_CABAC_BYPASS_ALIGN_1_HIGH_TP_444_14BIT_RExt_Apple_2.bit WPP_AND_TILE_HIGH_TP_444_8BIT_RExt_Apple_2.bit you can download them from: https://www.itu.int/wftp3/av-arch/jctvc-site/bitstream_exchange/draft_conformance/RExt/ Signed-off-by: Xu Guangxin <oddstone@gmail.com> Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
* avcodec/notchlc: Check uncompressed size against input for LZ4Michael Niedermayer2021-01-03
| | | | | | | | | Fixes: OOM Fixes: 26168/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-6019839015256064 Fixes: 28397/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5649039941042176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* avcodec/videotoolbox: make FFmpeg-to-VT mapping error more informativeJan Ekström2021-01-02
| | | | Now logs the actual failed-to-map pixel format as well as range.
* Mark some pointers as constAndreas Rheinhardt2021-01-01
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* lavc/mjpegdec: cosmetics, org->origAnton Khirnov2021-01-01
|
* mpegvideo: use the AVVideoEncParams API for exporting QP tablesAnton Khirnov2021-01-01
| | | | | | | | | | Do it only when requested with the AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS flag. Drop previous code using the long-deprecated AV_FRAME_DATA_QP_TABLE* API. Temporarily disable fate-filter-pp, fate-filter-pp7, fate-filter-spp. They will be reenabled once these filters are converted in following commits.
* lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bumpAnton Khirnov2021-01-01
| | | | They are not properly namespaced and not intended for public use.
* lavu: move LOCAL_ALIGNED from internal.h to mem_internal.hAnton Khirnov2021-01-01
| | | | That is a more appropriate place for it.
* avcodec/svq1dec: Increase nb_bits of VLC to read it in one goAndreas Rheinhardt2020-12-31
| | | | | Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/dirac_arith: Make table only used here staticAndreas Rheinhardt2020-12-31
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/qdmc: Mark decoder as init-threadsafeAndreas Rheinhardt2020-12-31
| | | | | | | It already uses ff_thread_once() to initialize its static data. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/opusdec: Mark decoder as init-threadsafeAndreas Rheinhardt2020-12-31
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/opusdec: Cleanup generically on init failureAndreas Rheinhardt2020-12-31
| | | | | Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/opusdec: Move per-stream fields to OpusStreamContextAndreas Rheinhardt2020-12-31
| | | | | | | | Besides being more natural it also avoids allocations for separate arrays of decoded samples/output buffers/.... Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avcodec/opusdec: Return error upon errorAndreas Rheinhardt2020-12-31
| | | | | | | | | The Opus decoder forgot to return an error when allocating an SwrContext fails. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>