This patch modifies the encode frame function to
retry encoding the frame when the resulting bit count
is too far off target, but only adjusting lambda
in small, incremental step. It also makes the logic
more conservative - otherwise it will contend with
bit reservoir-related variations in bit allocation,
and result in artifacts when frame have to be truncated
(usually at high bit rates transitioning from low
complexity to high complexity).
Avoid clipping due to quantization noise to produce audible
artifacts, by detecting near-clipping signals and both attenuating
them a little and encoding escape-encoded bands (usually the
loudest) rounding towards zero instead of nearest, which tends to
decrease overall energy and thus clipping.
Currently fate tests measure numerical error so this change makes
tests using asynth (which are near clipping) report higher error
not less, because of window attenuation. Yet, they sound better,
not worse (albeit subtle, other samples aren't subtle at all).
Only measuring psychoacoustically weighted error would make for
a representative test, so that will be left for a future patch.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit adds the energy spread to the struct for each band and removes 2 unused fields.
distortion and perceptual_weight were not referenced in any file nor were they set to any value,
so it was safe to remove them. The energy spread is currently only used in the aac psy model.
It's defined as being proportional to the tonality of each band.
Reviewed-by: Claudio Freire <klaussfreire@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
* commit '040c565e51985477a8fa5e42d2ddfb26ebde6608':
doc: developer: Allow tabs in the vim configuration for Automake files
Remove pointless av_cold attributes in header files
Conflicts:
libavcodec/h264.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
The init functions marked as av_cold have to be executed in any case,
so there is no gain from trying to mark paths leading to such functions
as unlikely.
* qatar/master:
Remove ffmpeg.
aacenc: Simplify windowing
aacenc: Move saved overlap samples to the beginning of the same buffer as incoming samples.
aacenc: Deinterleave input samples before processing.
aacenc: Store channel count in AACEncContext.
aacenc: Move Q^3/4 calculation to it's own table
aacenc: Request normalized float samples instead of converting s16 samples to float.
aacpsy: Replace an if with FFMAX in LAME windowing.
aacenc: cosmetics, replace 'rd' with 'bits' in codebook_trellis_rate to make it more clear what is being calculated.
aacpsy: cosmetics, change a FIXME to a NOTE about subshort comparisons
aacenc: cosmetics: move init() and end() to the bottom of the file.
aacenc: aac_encode_init() cleanup
XWD encoder and decoder
vc1: don't read the interpfrm and bfraction elements for interlaced frames
mxfdec: fix memleak on mxf_read_close()
westwood: split the AUD and VQA demuxers into separate files.
Conflicts:
.gitignore
Changelog
Makefile
configure
doc/ffmpeg.texi
ffmpeg.c
libavcodec/Makefile
libavcodec/aacenc.c
libavcodec/allcodecs.c
libavcodec/avcodec.h
libavcodec/version.h
libavformat/Makefile
libavformat/img2.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* qatar/master:
rational-test: Add proper main() declaration to fix gcc warnings.
configure: Add vdpau and dxva2 to configure results output.
Remove unused, never built libavutil/pca.[ch]
matroskadec: forward parsing errors to caller.
av_find_stream_info: simplify EAGAIN handling.
aacenc: Fix determination of Mid/Side Mode.
psymodel: Remove the single channel analysis function
aacenc: Implement dummy channel group analysis that just calls the single channel analysis for each channel.
psymodel: Add channels and channel groups to the psymodel.
ARM: remove check for PLD instruction
fate: move amr[nw]b test rules into separate files
ogg: fix double free when finding length of small chained oggs.
swscale: implement >8bit scaling support.
build: fix creation of tools dir with make 3.81
build: Mark all-yes Makefile target as phony.
pixfmt: fix YUV422/444 wrong endian comment
build: create output directories as needed
Add new yuv444 pixfmts to avcodec_align_dimensions2
Conflicts:
Makefile
configure
libavutil/pca.c
libavutil/pca.h
libavutil/pixfmt.h
libswscale/swscale.c
libswscale/utils.c
libswscale/x86/swscale_template.c
tests/ref/lavfi/pixdesc
tests/ref/lavfi/pixfmts_copy
tests/ref/lavfi/pixfmts_null
tests/ref/lavfi/pixfmts_scale
tests/ref/lavfi/pixfmts_vflip
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* qatar/master:
log: Fix an oob array read.
cosmetics: trim trailing whitespace in postproc
Ban strncpy() it's too easy to misuse.
psymodel: Remove wrapper functions.
aacenc: Replace loop counters in aac_encode_frame() with more descriptive 'ch' and 'w'.
regtest: remove redundant flags in jpg test
regtest: use run_ffmpeg in do_image_formats
regtest: simplify encoding functions
ffmpeg.c: check for interlaced flag in the correct place.
Merged-by: Michael Niedermayer <michaelni@gmx.at>
* qatar/master:
psymodel: extend API to include PE and bit allocation.
avio: always compile dyn_buf functions
Remove unnecessary parameter from ff_thread_init() and fix behavior
Revert "aac_latm_dec: use aac context and aac m4ac"
configure: tell user if libva is enabled like the rest of external libs.
Add silence support for AV_SAMPLE_FMT_U8.
avio: make URL_PROTOCOL_FLAG_NESTED_SCHEME internal
avio: deprecate av_url_read_seek
avio: deprecate av_url_read_pause
ac3enc: NEON optimised extract_exponents
Conflicts:
libavcodec/utils.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>