History | View | Annotate | Download (57.8 KB)
ac3enc: fix bug in stereo rematrixing decision.
The rematrixing strategy reuse flags are not reset between frames, so theyneed to be initialized for all blocks, not just block 0.
Signed-off-by: Mans Rullgard <mans@mansr.com>(cherry picked from commit 5b54d4b376fbd2c291b8a6dba7d425e28f654bcf)
ac3enc: change default floor code to 7.
This is to match the value in every (E-)AC-3 file from commercial sources.It has a negligible effect on audio quality.
Signed-off-by: Mans Rullgard <mans@mansr.com>(cherry picked from commit 50d7140441b61809ad4ba4ea7b4ad8fe77bc6888)
Merge libavcore into libavutil
Done to keep ABI compatible. Otherwise this is just silly
Add x86-optimized versions of exponent_min().
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>(cherry picked from commit dda3f0ef48aa5c3b03566b60b6bf63211e1fe579)
ac3enc: Change EXP_DIFF_THRESHOLD to 500.
This patch changes the exponent difference threshold in the exponentstrategy decision function of the AC-3 encoder. I tested lowering inincrements of 100. From 1000 down to 500 generally increased in qualitywith each step, but 400 was generally much worse....
Add ff_ prefix to ac3_common_init().
Signed-off-by: Mans Rullgard <mans@mansr.com>(cherry picked from commit 4c57cde942b3d28074d0bb06e2ca200bc1098f22)
ac3enc: use dsputil functions in apply_window()
Signed-off-by: Mans Rullgard <mans@mansr.com>(cherry picked from commit 3b924294ea0ab891cf28fb30f26962a7960f7f37)
cosmetics: spacing, line wrap, and remove unneeded braces
Originally committed as revision 26359 to svn://svn.ffmpeg.org/ffmpeg/trunk
Process all EXP_REUSE blocks at once in exponent_min().43% faster in function encode_exponents().
Originally committed as revision 26358 to svn://svn.ffmpeg.org/ffmpeg/trunk
Take advantage of per-channel exponent and exponent strategy layout tosimplify and speed up encode_exponents().8% faster in function.
Originally committed as revision 26357 to svn://svn.ffmpeg.org/ffmpeg/trunk
Simplify compute_exp_strategy() by passing a pointer to all exponents andexponent strategies for a single channel to compute_exp_strategy_ch().This allows for removal of the temporary pointer arrays.
Originally committed as revision 26356 to svn://svn.ffmpeg.org/ffmpeg/trunk
Use a local variable in the inner loop of group_exponents() to simplify thecode.
Originally committed as revision 26355 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: remove unneeded braces
Originally committed as revision 26354 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: rename block_num to blk for variable name consistency
Originally committed as revision 26353 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move exp_strategy from AC3Block to AC3EncodeContext in order to arrange bychannel first, then by block.
Originally committed as revision 26352 to svn://svn.ffmpeg.org/ffmpeg/trunk
Rearrange exponent buffer to group all blocks for a single channel together.This will allow for faster and simpler processing of all blocks at once.
Originally committed as revision 26351 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add stereo rematrixing support to the AC-3 encoders.This improves the audio quality significantly for stereo source with both thefixed-point and floating-point AC-3 encoders.Update acodec-ac3_fixed and seek-ac3_rm test references.
Originally committed as revision 26271 to svn://svn.ffmpeg.org/ffmpeg/trunk
Convert floating-point MDCT coefficients to 24-bit fixed-point all at onceinstead of doing it separately in 2 different functions.This makes float AC-3 encoding approx. 3-7% faster overall.Also, the coefficient conversion can now be easily SIMD-optimized....
Use local variables outside the inner loop in extract_exponents() to reduceaccessing of structs and arrays inside the loop.Approx. 30% faster in function extract_exponents().
Originally committed as revision 26226 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: fix typo in previous commit
Originally committed as revision 26210 to svn://svn.ffmpeg.org/ffmpeg/trunk
Change the AC-3 encoder to use floating-point.Fixed-point AC-3 encoder renamed to ac3_fixed.Regression test acodec-ac3 renamed to acodec-ac3_fixed.Regression test lavf-rm changed to use ac3_fixed encoder.
Originally committed as revision 26209 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move fixed-point parts of the AC-3 encoder to separate files.
Originally committed as revision 26206 to svn://svn.ffmpeg.org/ffmpeg/trunk
Skip the bit allocation search if previous and current SNR offsets are themaximum value of 1023.This speeds up overall encoding depending on the content and bitrate.The most improvement is with high bitrates and/or low complexity content.
Originally committed as revision 26181 to svn://svn.ffmpeg.org/ffmpeg/trunk
10l: Fix mistake in r26044. Check increment bounds using actual incrementinstead of 64. This will change output in some cases, but it happens to notaffect the AC-3 regression tests.
Originally committed as revision 26180 to svn://svn.ffmpeg.org/ffmpeg/trunk
Change planar_samples from int16_t to SampleType.This one was missed in r26174.
Originally committed as revision 26179 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add typedefs and a macro that will allow sharing of functions between thefixed-point and floating-point AC-3 encoders.
Originally committed as revision 26174 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move the list of supported channel layouts to a separate table.
Originally committed as revision 26173 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add a window field to AC3MDCTContext and use it as an input to apply_window()instead of using the ff_ac3_window[] table directly.
Originally committed as revision 26172 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: alignment, line wrap, and spacing
Originally committed as revision 26171 to svn://svn.ffmpeg.org/ffmpeg/trunk
Remove avctx from AC3MDCTContext and just pass it to mdct_init() instead.
Originally committed as revision 26170 to svn://svn.ffmpeg.org/ffmpeg/trunk
Make exponent_group_tab[] static.
Originally committed as revision 26169 to svn://svn.ffmpeg.org/ffmpeg/trunk
Change the default dB-per-bit code from 2 to 3.This gives slightly better quality in PEAQ tests.Code 3 gives a dBpb value of 2816 = -132dB (128 psd units = -6dB), whichcorresponds to 22 bits. Since the exponents have an offset applied, the16-bit source looks like 24-bit source to the bit allocation routine....
cosmetics: line wrap and vertical alignment
Originally committed as revision 26084 to svn://svn.ffmpeg.org/ffmpeg/trunk
Make sure that the 2nd CRC value does not match the AC-3 sync word.This is optional for encoders, but it's a good idea and has minimal impacton performance.This will change the output for some files, but it happens not to affect theregression tests.
Originally committed as revision 26083 to svn://svn.ffmpeg.org/ffmpeg/trunk
Store CRC context locally to reduce number of calls to av_crc_get_table().
Originally committed as revision 26082 to svn://svn.ffmpeg.org/ffmpeg/trunk
Remove unneeded local variable, frame_size, in output_frame_end().
Originally committed as revision 26081 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: fix comment after change in clipping range
Originally committed as revision 26072 to svn://svn.ffmpeg.org/ffmpeg/trunk
Change FIX15 back to clipping to -32767..32767.This avoids a 16-bit overflow in mdct512() due to a -32768 value in costab.References updated for acodec-ac3, lavf-rm, and seek-ac3_rm tests.Thanks to Måns Rullgård for finding the bug.
Originally committed as revision 26071 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add emms_c() after exp_diff calculations.Fixes AC-3 encoding on OpenBSD 4.8 x86_32 and hopefully other similarconfigurations.
Originally committed as revision 26070 to svn://svn.ffmpeg.org/ffmpeg/trunk
Pre-calculate crc_inv at codec init.20% faster output_frame_end().
Originally committed as revision 26069 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add some simple fallbacks for normal bit allocation failure.This allows encoding with lower bitrates by decreasing exponent bits first,then decreasing bandwidth if the user did not specify a specific cutofffrequency.
Originally committed as revision 26050 to svn://svn.ffmpeg.org/ffmpeg/trunk
Check user-specified cutoff frequency in validate_options().
Originally committed as revision 26049 to svn://svn.ffmpeg.org/ffmpeg/trunk
10l: fix encoding for LFE channel
Originally committed as revision 26048 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add support for fixed-point MDCT sizes other than 512.
Originally committed as revision 26046 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: reindent after last commit
Originally committed as revision 26045 to svn://svn.ffmpeg.org/ffmpeg/trunk
Simplify bit allocation search by using a loop for the SNR offset increment.
Originally committed as revision 26044 to svn://svn.ffmpeg.org/ffmpeg/trunk
Do not calculate psd and masking curve if exponents are being reused.Approx. 20% faster in function bit_alloc_masking().
Originally committed as revision 26042 to svn://svn.ffmpeg.org/ffmpeg/trunk
Originally committed as revision 26041 to svn://svn.ffmpeg.org/ffmpeg/trunk
Copy bap from previous block when exponent strategy is EXP_REUSE.We can do this because exponents are the only bit allocation parameters whichchange from block-to-block currently.Approx. 57% faster in function bit_alloc().Approx. 25% faster overall encoding....
Count grouped mantissas for each block all at once at the end of bitallocation for each block.24% faster in function bit_alloc(). Approx. 10% faster overall encoding.
Originally committed as revision 26039 to svn://svn.ffmpeg.org/ffmpeg/trunk
Count bits for fixed parameters at start of encoding rather than in everyframe.
Originally committed as revision 26038 to svn://svn.ffmpeg.org/ffmpeg/trunk
Use a LUT for number of exponent groups. This avoids recalculating it forevery block and channel for every frame.
Originally committed as revision 26037 to svn://svn.ffmpeg.org/ffmpeg/trunk
Speed up group minimum and group output calculations for EXP_D25 and EXP_D45in encode_exponents_blk_ch() by removing the inner loops. This is about 30-40%faster for the modified sections.
Originally committed as revision 26036 to svn://svn.ffmpeg.org/ffmpeg/trunk
Convert a for() loop into a while() loop for the downward part of the exponentdelta limiting.
Originally committed as revision 26035 to svn://svn.ffmpeg.org/ffmpeg/trunk
Redesign encode_exponents_blk_ch() so that duplicate exponent sets are nolonger required. This gets rid of the temp buffer as well as encoded_exp inAC3EncodeContext. It also allows for skipping the exponent grouping forEXP_D15. 56% faster in encode_exponents_blk_ch()....
Use optimized function DSPContext.sad0() instead of calc_exp_diff().90% faster compute_exp_strategy().
Originally committed as revision 26033 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: pretty-printing after last commit
Originally committed as revision 26031 to svn://svn.ffmpeg.org/ffmpeg/trunk
Add a goto for init failure instead of duplicate calls to ac3_encode_close().
Originally committed as revision 26030 to svn://svn.ffmpeg.org/ffmpeg/trunk
Use pre-allocated temp buffers in mdct512().5% faster in function.
Originally committed as revision 26029 to svn://svn.ffmpeg.org/ffmpeg/trunk
Write results of post-rotation complex multiply directly to output.2% faster in function mdct512().
Originally committed as revision 26028 to svn://svn.ffmpeg.org/ffmpeg/trunk
Use memcpy() instead of a for loop in mdct512().8% faster in function.
Originally committed as revision 26027 to svn://svn.ffmpeg.org/ffmpeg/trunk
Allocate all large per-channel arrays using av_malloc().Decreases memory usage for less than 6 channels.
Originally committed as revision 26026 to svn://svn.ffmpeg.org/ffmpeg/trunk
Make windowed_samples 16-byte aligned.This will allow future SIMD optimization of the window function.
Originally committed as revision 26025 to svn://svn.ffmpeg.org/ffmpeg/trunk
Allocate planar_samples using av_mallocz().Lowers memory usage when encoding less than 6 channels.
Originally committed as revision 26024 to svn://svn.ffmpeg.org/ffmpeg/trunk
Allocate bap and bap1 buffers using av_malloc().This reduces the memory footprint when using less than 6 channels.Modify bit allocation to swap the 2 buffers instead of using memcpy() and useper-block pointers for bap. This is slightly faster (0.3%) in function...
Remove last_samples[] and copy directly from planar_samples[].Avoids memcpy that was used to store last samples for next frame.Approx. 3% faster in function deinterleave_input_samples() and reduces memoryusage by 3kB.
Originally committed as revision 26021 to svn://svn.ffmpeg.org/ffmpeg/trunk
Remove unneeded line. key_frame is already set to 1 in avcodec_alloc_frame().
Originally committed as revision 26020 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: comment clean-up and misc cosmetics
Originally committed as revision 26019 to svn://svn.ffmpeg.org/ffmpeg/trunk
Separate most of the per-block arrays into a separate per-block struct.
Originally committed as revision 26018 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split bit allocation search into a separate function.
Originally committed as revision 26017 to svn://svn.ffmpeg.org/ffmpeg/trunk
10l: fix typo in compute_exp_strategy()
Originally committed as revision 26013 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move large arrays to AC3EncodeContext rather than passing them around.
Originally committed as revision 26012 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: line wrap and spacing
Originally committed as revision 26011 to svn://svn.ffmpeg.org/ffmpeg/trunk
Use a single value for SNR offset in the bit allocation search rather thanthe separate coarse and fine values.
Originally committed as revision 26010 to svn://svn.ffmpeg.org/ffmpeg/trunk
Change bit_alloc() to return the mantissa bit count.
Originally committed as revision 26009 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: alignment and line wrap after last commit
Originally committed as revision 26008 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move bit counts to AC3EncodeContext.
Originally committed as revision 26007 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split out setting of bit allocation parameters to a separate function.Th new function only needs to be called at initialization because bitallocation parameters currently do not change during encoding.
Originally committed as revision 26003 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split out counting of frame bits into a separate function.
Originally committed as revision 26002 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: vertical alignment
Originally committed as revision 26001 to svn://svn.ffmpeg.org/ffmpeg/trunk
Only calculate num_exp_groups once.
Originally committed as revision 26000 to svn://svn.ffmpeg.org/ffmpeg/trunk
Check for bit allocation error in ac3_encode_frame().Move error log printout to ac3_encode_frame().
Originally committed as revision 25999 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split out grouping of exponents into a separate function.
Originally committed as revision 25998 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split out mantissa quantization into separate functions.
Originally committed as revision 25997 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: rearrange some functions
Originally committed as revision 25996 to svn://svn.ffmpeg.org/ffmpeg/trunk
Reverse the exponent & exponent strategy array arrangement to simplify theper-channel exponent strategy decision. This will also make it easier toplug-in other exponent strategy algorithms.
Originally committed as revision 25995 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move writing of frame to the output bitstream to a separate function.
Originally committed as revision 25994 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: remove a comment and just spacing
Originally committed as revision 25993 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split frame size adjustment into a separate function.
Originally committed as revision 25992 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split exponent processing into separate functions.
Originally committed as revision 25991 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split applying of MDCT into several separate functions.
Originally committed as revision 25990 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split input sample deinterleaving into a separate function.
Originally committed as revision 25989 to svn://svn.ffmpeg.org/ffmpeg/trunk
Separate functionally different calculations in ac3_encode_frame().
Originally committed as revision 25988 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: rename 2 variables
Originally committed as revision 25987 to svn://svn.ffmpeg.org/ffmpeg/trunk
Deinterleave whole frame at once instead of per-block.This reduces the amount of memcpy() by using pointers to overlap samples forsuccessive blocks rather than copying.
Originally committed as revision 25986 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: add & alter some comments
Originally committed as revision 25985 to svn://svn.ffmpeg.org/ffmpeg/trunk
Split setting of bandwidth into a separate function.
Originally committed as revision 25984 to svn://svn.ffmpeg.org/ffmpeg/trunk
Move setting of bitstream_id and bitstream_mode to ac3_encode_init().
Originally committed as revision 25983 to svn://svn.ffmpeg.org/ffmpeg/trunk
Improve ac3_encode_init() error reporting.Return AVERROR instead of -1. Propogate errors from called functions.Add some error log printouts.
Originally committed as revision 25982 to svn://svn.ffmpeg.org/ffmpeg/trunk
cosmetics: indent after last commit
Originally committed as revision 25981 to svn://svn.ffmpeg.org/ffmpeg/trunk