On Fri, Jul 17, 2015 at 08:57:55AM -0300, Claudio Freire wrote: > 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.
> libavcodec/aac.h | 1 > libavcodec/aaccoder.c | 108 > ++++++++++++++++++++++++++++++++------------------ > libavcodec/aacenc.c | 28 ++++++++++++ > libavcodec/aacenc.h | 2 > libavcodec/aacpsy.c | 31 ++++++++++++++ > libavcodec/psymodel.h | 1 > tests/fate/aac.mak | 2 > 7 files changed, 132 insertions(+), 41 deletions(-) > 639d32c84ff9906d545e483673f70d57ef7bfa67 > 0001-AAC-Encoder-clipping-avoidance.patch > From 9da94f02574b34025a56c225c11269802f49949b Mon Sep 17 00:00:00 2001 > From: Claudio Freire <klaussfre...@gmail.com> > Date: Fri, 17 Jul 2015 05:47:25 -0300 > Subject: [PATCH] AAC Encoder: clipping avoidance [...] > diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c > index f05f51b..6ff95b1 100644 > --- a/libavcodec/aacenc.c > +++ b/libavcodec/aacenc.c > @@ -46,6 +46,7 @@ > #include "psymodel.h" > > #define AAC_MAX_CHANNELS 6 > +#define CLIP_AVOIDANCE_FACTOR 0.95f > > #define ERROR_IF(cond, ...) \ > if (cond) { \ > @@ -473,7 +474,29 @@ static void encode_spectral_coeffs(AACEncContext *s, > SingleChannelElement *sce) > sce->ics.swb_sizes[i], > sce->sf_idx[w*16 + i], > sce->band_type[w*16 + i], > - s->lambda); > + s->lambda, > sce->ics.window_clipping[w]); > + start += sce->ics.swb_sizes[i]; > + } > + } > +} > + > +/** > + * Downscale spectral coefficients for near-clipping windows to avoid > artifacts > + */ > +static void avoid_clipping(AACEncContext *s, SingleChannelElement *sce) > +{ > + int start, i, j, w, w2; > + > + for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { > + start = 0; > + for (i = 0; i < sce->ics.max_sfb; i++) { > + if (sce->ics.window_clipping[w]) { > + for (w2 = w; w2 < w + sce->ics.group_len[w]; w2++) { > + float *swb_coeffs = sce->coeffs + start + w2*128; > + for (j = 0; j < sce->ics.swb_sizes[i]; j++) > + swb_coeffs[j] *= CLIP_AVOIDANCE_FACTOR; > + } > + } wouldnt it be better to transition smoothly instead of a hard *0.95 vs. *1 ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel