1. 28 Nov, 2015 1 commit
  2. 17 Oct, 2015 1 commit
    • Rostislav Pehlivanov's avatar
      aacenc: add support for encoding files using Long Term Prediction · 27d23ae0
      Rostislav Pehlivanov authored
      Long Term Prediction allows for prediction of spectral coefficients
      via the previously decoded time-dependent samples. This feature
      works well with harmonic content 2 or more frames long, like speech,
      human or non-human, piano music or any constant tones at very low
      bitrates.
      
      It should be noted that the current coder is highly efficient and
      the rate control system is unable to encode files at extremely
      low bitrates (less than 14kbps seems to be impossible) so this
      extension isn't capable of optimum operation. Dramatic difference
      is observable with some types of audio and speech but for the most
      part the audiable differences are subtle. The spectrum looks better
      however so the encoder is able to harvest the additional bits that
      this feature provies, should the user choose to enable it. So
      it's best to enable this feature only if encoding at the absolutely
      lowest bitrate that the encoder is capable of.
      27d23ae0
  3. 11 Oct, 2015 1 commit
    • Claudio Freire's avatar
      AAC encoder: Extensive improvements · 01ecb717
      Claudio Freire authored
      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.
      01ecb717
  4. 29 Aug, 2015 2 commits
    • Rostislav Pehlivanov's avatar
      aac: remove now-unused redundant array · 1cd5daee
      Rostislav Pehlivanov authored
      This commit removes the array which was made redundant with
      the last commit. The current prediction system gets the
      quantization error directly (and without the single-frame delay)
      in the search_for_pred function.
      Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
      1cd5daee
    • Rostislav Pehlivanov's avatar
      aacenc_pred: rework the way prediction is done · 44ddee94
      Rostislav Pehlivanov authored
      This commit completely alters the algorithm of prediction.
      The original commit which introduced prediction was completely
      incorrect to even remotely care about what the actual coefficients
      contain or whether any options were enabled. Not my actual fault.
      
      This commit treats prediction the way the decoder does and expects
      to do: like lossy encryption. Everything related to prediction now
      happens at the very end but just before quantization and encoding
      of coefficients. On the decoder side, prediction happens before
      anything has had a chance to even access the coefficients.
      
      Also the original implementation had problems because it actually
      touched the band_type of special bands which already had their
      scalefactor indices marked and it's a wonder the asserion wasn't
      triggered when transmitting those.
      
      Overall, this now drastically increases audio quality and you should
      think about enabling it if you don't plan on playing anything encoded
      on really old low power ultra-embedded devices since they might not
      support decoding of prediction or AAC-Main. Though the specifications
      were written ages ago and as times change so do the FLOPS.
      Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
      44ddee94
  5. 21 Aug, 2015 3 commits
    • Rostislav Pehlivanov's avatar
      aacenc: implement the complete AAC-Main profile · 76b81b10
      Rostislav Pehlivanov authored
      This commit finalizes AAC-Main profile encoding support
      by implementing all mandatory and optional tools available
      in the specifications and current decoders.
      
      The AAC-Main profile reqires that prediction support be
      present (although decoders don't require it to be enabled)
      for an encoder to be deemed capable of AAC-Main encoding,
      as well as TNS, PNS and IS, all of which were implemented
      with previous commits or earlier of this year.
      
      Users are encouraged to test the new functionality using either
      -profile:a aac_main or -aac_pred 1, the former of which will enable
      the prediction option by default and the latter will change the
      profile to AAC-Main. No other options shall be changed by enabling
      either, it's currently up to the users to decide what's best.
      
      The current implementation works best using M/S and/or IS,
      so users are also welcome to enable both options and any
      other options (TNS, PNS) for maximum quality.
      Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
      76b81b10
    • Rostislav Pehlivanov's avatar
      aacenc_tns: implement temporal noise shaping · a1c487e9
      Rostislav Pehlivanov authored
      This commit implements temporal noise shaping support in the
      encoder, along with an -aac_tns option to toggle it on or off
      (off by default for now). TNS will increase audio quality
      and reduce quantization noise by applying a multitap FIR filter
      across allowed coefficients and transmit side information to the
      decoder so it could create an inverse filter.
      
      Users are encouraged to test the new functionality by enabling
      -aac_tns 1 during encoding.
      
      No major bugs are observable at this time so after a while if no
      new problems appear and if the current implementation is deemed
      of high enough quality and stability it will be enabled by default,
      possibly at the same time the encoder has its experimental flag
      removed and becomes the standard aac encoder in ffmpeg.
      Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
      a1c487e9
    • Rostislav Pehlivanov's avatar
      aaccoder: move the quantization functions to a separate file · 43b378a0
      Rostislav Pehlivanov authored
      This commit moves the quantizer to a separate header file.
      This allows the quantizer to be used from a separate files outside
      of aaccoder without having to put another function pointer and will
      result in a slight speedup as the compiler can do more optimizations.
      
      This is required for commits following.
      Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
      43b378a0
  6. 27 Jul, 2015 1 commit
    • Claudio Freire's avatar
      AAC Encoder: clipping avoidance · 59216e05
      Claudio Freire authored
      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: 's avatarMichael Niedermayer <michael@niedermayer.cc>
      59216e05
  7. 20 Jul, 2015 1 commit
  8. 09 Jul, 2015 2 commits
  9. 27 Jun, 2015 1 commit
  10. 14 Apr, 2015 1 commit
  11. 13 Apr, 2015 1 commit
    • Rostislav Pehlivanov's avatar
      aacenc: Add support for Perceptual Noise Substitution energy values · f7f71b57
      Rostislav Pehlivanov authored
      This commit implements support for writing the noise energy values used in PNS.
      The difference between regular scalefactors and noise energy values is that the latter
      require a small preamble (NOISE_PRE + energy_value_diff) to be written as the first
      noise-containing band. Any following noise energy values use the previous one to
      base their "diff" on. Ordinary scalefactors remain unchanged other than that they ignore the noise values.
      
      This commit should not change anything by itself, the following commits will bring it in use.
      Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
      f7f71b57
  12. 03 Mar, 2015 1 commit
    • Claudio Freire's avatar
      AAC: Fix M/S stereo encoding · 6394acaf
      Claudio Freire authored
      This patch fixes a pointer arithmetic bug in adjust_frame_information that resulted in heavily corrupted audio when using M/S encoding. Also, a backup copy of untransformed coefficients has to be kept around or attempts at re-processing the frame (which happens when hevavily overspending bits during transients) will result in re-encoding of the coefficients and subsequent corruption of the resulting stream.
      
      A/B testing shows the bug as corrected, but still cannot prove that M/S coding is a win at least in numbers. Limited listening tests do show improvement on M/S encoded samples in lower bitrates, but they're hidden among the other artifacts that remain to be corrected in the encoder.
      
      Some of the regressions flagged in the report do show poor stereo image (but not buggy), so M/S encoding is clearly not good enough yet to be defaulted to auto.
      
      In numbers, Patched against Unpatched, stereo_mode auto:
      
        Files: 114
        Bitrates: 6
        Tests: 683
      
        Serious Regressions: 0 (0%)
        Regressions: 0 (0%)
        Improvements: 227 (33%)
        Big improvements: 92 (13%)
        Worst regression - mybloodrusts.wv - 256k
          - StdDev: 28.61       pSNR: -0.43     maxdiff: 1372.00
        Best improvement - 60.wv - 384k
          - StdDev: -369.57     pSNR: 45.02     maxdiff: -13322.00
        Average          - StdDev: -80.56       pSNR: 2.49      maxdiff: -8858.00
      
      Patched against Unpatched stereo_mode ms_off shows no difference.
      
      Patched stereo_mode auto vs Unpatched stereo_mode ms_off shows a small average improvement, just not too significant:
      
        Serious Regressions: 0 (0%)
        Regressions: 10 (1%)
        Improvements: 45 (6%)
        Big improvements: 2 (0%)
        Worst regression - Illinois.wv - 256k
          - StdDev: 33.20       pSNR: -2.03     maxdiff: 477.00
        Best improvement - song_of_circomstances.flac - 384k
          - StdDev: -3.97       pSNR: 7.61      maxdiff: -826.00
        Average          - StdDev: -10.25       pSNR: 0.20      maxdiff: -281.00
      Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
      6394acaf
  13. 28 Feb, 2015 1 commit
  14. 04 Feb, 2015 1 commit
  15. 02 Dec, 2014 1 commit
  16. 09 Nov, 2014 1 commit
  17. 24 Oct, 2014 1 commit
  18. 25 May, 2014 1 commit
  19. 23 Oct, 2013 1 commit
  20. 18 Sep, 2013 1 commit
  21. 25 Jul, 2013 1 commit
  22. 08 Mar, 2013 1 commit
  23. 07 Mar, 2013 1 commit
  24. 25 Feb, 2013 1 commit
  25. 21 Feb, 2013 1 commit
  26. 12 Feb, 2013 1 commit
  27. 31 Jan, 2013 1 commit
  28. 22 Jan, 2013 1 commit
  29. 30 Dec, 2012 2 commits
  30. 26 Nov, 2012 1 commit
  31. 18 Oct, 2012 1 commit
    • Mans Rullgard's avatar
      aac: fix build with hardcoded tables · 7a12d97e
      Mans Rullgard authored
      aac_tablegen.h includes aac.h for the POW_SF2_ZERO definition, but
      this also pulls in a raft of other headers, some of which are not
      safe to use in code built with the host compiler.
      
      Moving POW_SF2_ZERO to aac_tablegen_decl.h, where the declaration
      of the array it relates to already resides, fixes the problems.
      Signed-off-by: 's avatarMans Rullgard <mans@mansr.com>
      7a12d97e
  32. 06 Oct, 2012 1 commit
  33. 15 Sep, 2012 1 commit
    • Akihiro Tsukada's avatar
      aacdec: add support for dual mono in Japanese DTV · c3c646a8
      Akihiro Tsukada authored
      Japanese DTV uses some non standard extensions in AAC audio.
      One example is 'dual mono', which combines two independent
      audio into one stereo stream, storing them in left and right channels
      respectively.  Historically, dual mono audio has been used for
      multi-lingual audio, one for local/native language, and another for english,
      and usually the "main" (local language) channel should be output without
      any user interactions.
      
      The frames of those dual mono audio are allowed to set
      ADTS channel_config field to 0, and just contain two SCE's *WITHOUT* PCE,
      which is a non standard extension by Japanese DTV standard.
      (ref. ARIB STD-B32 PartII 5.2.3)
      
      This patch adds an AVPacket side data, AV_PKT_DATA_JP_DUALMONO,
      which indicates that the AVPacket is likely to contain an audio frame
      with the above dual mono extension, and has the parameter to specify
      the desired channel selection in that case.
      It also makes aacdec to detect dual mono and output just the desired
      channel when this side data is attached.
      Signed-off-by: 's avatarAkihiro Tsukada <atsukada@users.sourceforge.net>
      Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
      c3c646a8
  34. 08 Jun, 2012 1 commit
  35. 16 Apr, 2012 1 commit
    • Alex Converse's avatar
      aacdec: More robust output configuration. · 9fb7e146
      Alex Converse authored
      Save the old output configuration (if it has been used
      successfully) when trying a new configuration. If the new configuration
      fails to decode, restore the last successful configuration.
      9fb7e146