1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-08-10 11:25:05 +02:00
Commit Graph

41 Commits

Author SHA1 Message Date
Ganesh Ajjanagadde
8dbffda0f9 lavc/psymodel: check for av_malloc failure
No idea why in commit 01ecb7172b the
checks were removed; this can lead to NULL pointer dereferences. This
effectively reverts that portion of the commit.

Reviewed-by: Benoit Fouet <benoit.fouet@free.fr>
Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>
2016-03-23 08:22:22 -07:00
Claudio Freire
ca203e9985 AAC encoder: improve SF range utilization
This patch does 4 things, all of which interact and thus it
woudln't be possible to commit them separately without causing
either quality regressions or assertion failures.

Fate comparison targets don't all reflect improvements in
quality, yet listening tests show substantially improved quality
and stability.

1. Increase SF range utilization.

The spec requires SF delta values to be constrained within the
range -60..60. The previous code was applying that range to
the whole SF array and not only the deltas of consecutive values,
because doing so requires smarter code: zeroing or otherwise
skipping a band may invalidate lots of SF choices.

This patch implements that logic to allow the coders to utilize
the full dynamic range of scalefactors, increasing quality quite
considerably, and fixing delta-SF-related assertion failures,
since now the limitation is enforced rather than asserted.

2. PNS tweaks

The previous modification makes big improvements in twoloop's
efficiency, and every time that happens PNS logic needs to be
tweaked accordingly to avoid it from stepping all over twoloop's
decisions. This patch includes modifications of the sort.

3. Account for lowpass cutoff during PSY analysis

The closer PSY's allocation is to final allocation the better
the quality is, and given these modifications, twoloop is now
very efficient at avoiding holes. Thus, to compute accurate
thresholds, PSY needs to account for the lowpass applied
implicitly during twoloop (by zeroing high bands).

This patch makes twoloop set the cutoff in psymodel's context
the first time it runs, and makes PSY account for it during
threshold computation, making PE and threshold computations
closer to the final allocation and thus achieving better
subjective quality.

4. Tweaks to RC lambda tracking loop in relation to PNS

Without this tweak some corner cases cause quality regressions.
Basically, lambda needs to react faster to overall bitrate
efficiency changes since now PNS can be quite successful in
enforcing maximum bitrates, when PSY allocates too many bits
to the lower bands, suppressing the signals RC logic uses to
lower lambda in those cases and causing aggressive PNS.

This tweak makes PNS much less aggressive, though it can still
use some further tweaks.

Also update MIPS specializations and adjust fuzz

Also in lavc/mips/aacpsy_mips.h: remove trailing whitespace
2015-12-02 07:47:37 -03:00
Claudio Freire
323d37521d AAC encoder: cosmetics from last commit
Reindent
2015-10-11 18:06:02 -03:00
Claudio Freire
01ecb7172b AAC encoder: Extensive improvements
This finalizes merging of the work in the patches in ticket #2686.

Improvements to twoloop and RC logic are extensive.

The non-exhaustive list of twoloop improvments includes:
 - Tweaks to distortion limits on the RD optimization phase of twoloop
 - Deeper search in twoloop
 - PNS information marking to let twoloop decide when to use it
   (turned out having the decision made separately wasn't working)
 - Tonal band detection and priorization
 - Better band energy conservation rules
 - Strict hole avoidance

For rate control:
 - Use psymodel's bit allocation to allow proper use of the bit
   reservoir. Don't work against the bit reservoir by moving lambda
   in the opposite direction when psymodel decides to allocate more/less
   bits to a frame.
 - Retry the encode if the effective rate lies outside a reasonable
   margin of psymodel's allocation or the selected ABR.
 - Log average lambda at the end. Useful info for everyone, but especially
   for tuning of the various encoder constants that relate to lambda
   feedback.

Psy:
 - Do not apply lowpass with a FIR filter, instead just let the coder
   zero bands above the cutoff. The FIR filter induces group delay,
   and while zeroing bands causes ripple, it's lost in the quantization
   noise.
 - Experimental VBR bit allocation code
 - Tweak automatic lowpass filter threshold to maximize audio bandwidth
   at all bitrates while still providing acceptable, stable quality.

I/S:
 - Phase decision fixes. Unrelated to #2686, but the bugs only surfaced
   when the merge was finalized. Measure I/S band energy accounting for
   phase, and prevent I/S and M/S from being applied both.

PNS:
 - Avoid marking short bands with PNS when they're part of a window
   group in which there's a large variation of energy from one window
   to the next. PNS can't preserve those and the effect is extremely
   noticeable.

M/S:
 - Implement BMLD protection similar to the specified in
   ISO-IEC/13818:7-2003, Appendix C Section 6.1. Since M/S decision
   doesn't conform to section 6.1, a different method had to be
   implemented, but should provide equivalent protection.
 - Move the decision logic closer to the method specified in
   ISO-IEC/13818:7-2003, Appendix C Section 6.1. Specifically,
   make sure M/S needs less bits than dual stereo.
 - Don't apply M/S in bands that are using I/S

Now, this of course needed adjustments in the compare targets and
fuzz factors of the AAC encoder's fate tests, but if wondering why
the targets go up (more distortion), consider the previous coder
was using too many bits on LF content (far more than required by
psy), and thus those signals will now be more distorted, not less.

The extra distortion isn't audible though, I carried extensive
ABX testing to make sure.

A very similar patch was also extensively tested by Kamendo2 in
the context of #2686.
2015-10-11 17:29:50 -03:00
Michael Niedermayer
615e73ab4f Merge commit '03927cb73399e6f07185fc7f8851d7612b4187b6'
* commit '03927cb73399e6f07185fc7f8851d7612b4187b6':
  psymodel: Check memory allocation

Conflicts:
	libavcodec/psymodel.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-01 02:23:32 +02:00
Vittorio Giovara
03927cb733 psymodel: Check memory allocation 2015-05-31 15:03:31 +02:00
Michael Niedermayer
f43ac02723 avcodec/iirfilter: Make ff_iir_filter_free_state() also zero the freed pointer
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-14 20:46:15 +02:00
Michael Niedermayer
43fb16cf74 avcodec/iirfilter: Change ff_iir_filter_free_coeffs() so it clears the pointers as well
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-14 18:30:52 +02:00
Michael Niedermayer
d42a61922b avcodec/psymodel: use av_malloc(z)_array()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2014-04-13 23:36:59 +02:00
Carl Eugen Hoyos
f4aa8085f2 Avoid a null pointer dereference on oom in the aac encoder.
Fixes ticket #2732.
2013-06-30 23:25:18 +02:00
Bojan Zivkovic
7d29c6eebc mips: Optimization of IIR filter function
Signed-off-by: Bojan Zivkovic <bojan@mips.com>
Reviewed-by: Nedeljko Babic <Nedeljko.Babic@imgtec.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-20 12:44:32 +01:00
Michael Niedermayer
fee5da6b0a psymodel: dont apply lowpass filters with a cutoff close to the nyquist
The IIR filter numerically diverges in such cases, this could easily be
fixed but would make the filter slower on some platforms

Fixes Ticket2246

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-03-07 19:28:30 +01:00
Michael Niedermayer
c581cb4e4f Merge remote-tracking branch 'qatar/master'
* qatar/master:
  Fix even more missing includes after the common.h removal
  build: Factor out rangecoder dependencies to CONFIG_RANGECODER
  build: Factor out error resilience dependencies to CONFIG_ERROR_RESILIENCE
  x86: avcodec: Consistently name all init files
  Add more missing includes after removing the implicit common.h
  Add some more missing includes after removing the implicit common.h
  Don't include common.h from avutil.h
  rtmp: Automatically compute the hash for SWFVerification

Conflicts:
	configure
	doc/APIchanges
	doc/examples/decoding_encoding.c
	libavcodec/Makefile
	libavcodec/assdec.c
	libavcodec/audio_frame_queue.c
	libavcodec/avpacket.c
	libavcodec/dv_profile.c
	libavcodec/dwt.c
	libavcodec/libtheoraenc.c
	libavcodec/rawdec.c
	libavcodec/rv40dsp.c
	libavcodec/tiff.c
	libavcodec/tiffenc.c
	libavcodec/v210dec.h
	libavcodec/vc1dsp.c
	libavcodec/x86/Makefile
	libavfilter/asrc_anullsrc.c
	libavfilter/avfilter.c
	libavfilter/buffer.c
	libavfilter/formats.c
	libavfilter/vf_ass.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_select.c
	libavfilter/video.c
	libavfilter/vsrc_testsrc.c
	libavformat/version.h
	libavutil/audioconvert.c
	libavutil/error.h
	libavutil/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-16 16:20:30 +02:00
Martin Storsjö
1d9c2dc89a Don't include common.h from avutil.h
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-15 22:32:06 +03:00
Michael Niedermayer
7a72695c05 Merge commit '36ef5369ee9b336febc2c270f8718cec4476cb85'
* commit '36ef5369ee9b336febc2c270f8718cec4476cb85':
  Replace all CODEC_ID_* with AV_CODEC_ID_*
  lavc: add AV prefix to codec ids.

Conflicts:
	doc/APIchanges
	doc/examples/decoding_encoding.c
	doc/examples/muxing.c
	ffmpeg.c
	ffprobe.c
	ffserver.c
	libavcodec/8svx.c
	libavcodec/avcodec.h
	libavcodec/dnxhd_parser.c
	libavcodec/dvdsubdec.c
	libavcodec/error_resilience.c
	libavcodec/h263dec.c
	libavcodec/libvorbisenc.c
	libavcodec/mjpeg_parser.c
	libavcodec/mjpegenc.c
	libavcodec/mpeg12.c
	libavcodec/mpeg4videodec.c
	libavcodec/mpegvideo.c
	libavcodec/mpegvideo_enc.c
	libavcodec/pcm.c
	libavcodec/r210dec.c
	libavcodec/utils.c
	libavcodec/v210dec.c
	libavcodec/version.h
	libavdevice/alsa-audio-dec.c
	libavdevice/bktr.c
	libavdevice/v4l2.c
	libavformat/asfdec.c
	libavformat/asfenc.c
	libavformat/avformat.h
	libavformat/avidec.c
	libavformat/caf.c
	libavformat/electronicarts.c
	libavformat/flacdec.c
	libavformat/flvdec.c
	libavformat/flvenc.c
	libavformat/framecrcenc.c
	libavformat/img2.c
	libavformat/img2dec.c
	libavformat/img2enc.c
	libavformat/ipmovie.c
	libavformat/isom.c
	libavformat/matroska.c
	libavformat/matroskadec.c
	libavformat/matroskaenc.c
	libavformat/mov.c
	libavformat/movenc.c
	libavformat/mp3dec.c
	libavformat/mpeg.c
	libavformat/mpegts.c
	libavformat/mxf.c
	libavformat/mxfdec.c
	libavformat/mxfenc.c
	libavformat/nsvdec.c
	libavformat/nut.c
	libavformat/oggenc.c
	libavformat/pmpdec.c
	libavformat/rawdec.c
	libavformat/rawenc.c
	libavformat/riff.c
	libavformat/sdp.c
	libavformat/utils.c
	libavformat/vocenc.c
	libavformat/wtv.c
	libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-07 22:45:46 +02:00
Anton Khirnov
36ef5369ee Replace all CODEC_ID_* with AV_CODEC_ID_* 2012-08-07 16:00:24 +02:00
Michael Niedermayer
72dabdfc58 aacenc: new default cutoff
Improves subjective quality

Formula and testing by: kamedo2 <fujisakihir90@yahoo.co.jp>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-07-29 22:02:46 +02:00
Michael Niedermayer
c065255bba Merge remote-tracking branch 'qatar/master'
* qatar/master:
  aacenc: Fix LONG_START windowing.
  aacenc: Fix a bug where deinterleaved samples were stored in the wrong place.
  avplay: use the correct array size for stride.
  lavc: extend doxy for avcodec_alloc_context3().
  APIchanges: mention avcodec_alloc_context()/2/3
  avcodec_align_dimensions2: set only 4 linesizes, not AV_NUM_DATA_POINTERS.
  aacsbr: ARM NEON optimised sbrdsp functions
  aacsbr: align some arrays
  aacsbr: move some simdable loops to function pointers
  cosmetics: Remove extra newlines at EOF

Conflicts:
	libavcodec/utils.c
	libavfilter/formats.c
	libavutil/mem.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-01-29 00:34:59 +01:00
Alex Converse
7181c4edee cosmetics: Remove extra newlines at EOF 2012-01-27 17:19:09 -08:00
Michael Niedermayer
0bb57f8bf0 Merge remote-tracking branch 'qatar/master'
* 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>
2012-01-24 02:41:53 +01:00
Nathan Caldwell
9b8e2a8709 aacenc: Deinterleave input samples before processing.
Signed-off-by: Alex Converse <alex.converse@gmail.com>
2012-01-23 11:40:46 -08:00
Nathan Caldwell
025ccf1f8b aacenc: Request normalized float samples instead of converting s16 samples to float.
Signed-off-by: Alex Converse <alex.converse@gmail.com>
2012-01-23 11:40:46 -08:00
Michael Niedermayer
8c0cbb0848 Merge remote-tracking branch 'qatar/master'
* 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>
2011-06-30 04:32:24 +02:00
Nathan Caldwell
0bc01cc9fe psymodel: Add channels and channel groups to the psymodel. 2011-06-29 14:28:52 -07:00
Michael Niedermayer
6841c8c579 Merge remote branch 'qatar/master'
* 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>
2011-05-09 04:50:56 +02:00
Nathan Caldwell
b58e298572 psymodel: Remove wrapper functions.
Instead use the function pointers directly.
2011-05-08 12:43:04 -07:00
Mans Rullgard
2912e87a6c Replace FFmpeg with Libav in licence headers
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-03-19 13:33:20 +00:00
Justin Ruggles
99c2111b12 cosmetics: vertical alignment and line wrap
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 75b98610a7)
2011-01-21 20:36:01 +01:00
Justin Ruggles
20d1f6fec1 Add memory allocation failure checks to ff_iir_filter_init_coeffs().
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit d42dc217ed)
2011-01-21 20:36:01 +01:00
Justin Ruggles
75b98610a7 cosmetics: vertical alignment and line wrap
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-20 18:35:42 +00:00
Justin Ruggles
d42dc217ed Add memory allocation failure checks to ff_iir_filter_init_coeffs().
Signed-off-by: Mans Rullgard <mans@mansr.com>
2011-01-20 18:35:13 +00:00
Alex Converse
0e107f7890 psymodel: Const correct FFPsyWindowInfo.
Originally committed as revision 24999 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-08-30 23:48:35 +00:00
Martin Storsjö
771c86c13d Fix a leak in the AAC encoder
Originally committed as revision 24159 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-07-10 09:14:19 +00:00
Alex Converse
7ca4a72f47 10l: Revert r23867. It didn't make any sense.
Originally committed as revision 23868 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-28 21:40:38 +00:00
Alex Converse
9a3fe1ae6e Make ff_psy_preprocess_end() act like av_freep().
Originally committed as revision 23867 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-06-28 21:36:19 +00:00
Alex Converse
636da41a20 aacenc: Don't lowpass the input unless specifically requested.
The heuristic for estimating a good cutoff is busted.

Originally committed as revision 22779 to svn://svn.ffmpeg.org/ffmpeg/trunk
2010-04-02 14:19:39 +00:00
Alex Converse
2876a9dbaf Use cutoff frequency to adjust bandwidth in the generic psymodel preprocess.
Originally committed as revision 19429 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-07-14 05:22:23 +00:00
Diego Biurrun
c8f47d8b79 cosmetics: Remove unnecessary {} around if/for blocks;
move statements after if/for to the next line.

Originally committed as revision 19378 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-07-08 21:36:33 +00:00
Diego Biurrun
99d61d340c cosmetics: prettyprinting, K&R style, break overly long lines
Originally committed as revision 19377 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-07-08 21:16:06 +00:00
Alex Converse
fd257dc4c0 Cosmetics: Pretty print the AAC encoder.
Originally committed as revision 19376 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-07-08 20:36:45 +00:00
Alex Converse
78e65cd772 Merge the AAC encoder from SoC svn. It is still considered experimental.
Originally committed as revision 19375 to svn://svn.ffmpeg.org/ffmpeg/trunk
2009-07-08 20:01:31 +00:00