Message ID | 8e6e9b86-4fbf-3710-25f1-eb826182b381@googlemail.com |
---|---|
State | Superseded |
Headers | show |
On 13.11.2016 21:29, Andreas Cadhalpun wrote: > It causes division by zero crashes. > > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavcodec/aacsbr_fixed.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c > index b26314a..d2a7027 100644 > --- a/libavcodec/aacsbr_fixed.c > +++ b/libavcodec/aacsbr_fixed.c > @@ -429,6 +429,10 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, > av_add_sf(FLOAT_1, sbr->e_curr[e][m]), > av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); > } > + if (sbr->gain[e][m].mant == 0) { > + sbr->gain[e][m] = FLOAT_1; > + sbr->gain[e][m].exp = MIN_EXP; > + } > } > for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { > sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]); > Ping. It would be good to have this fixed in 3.2.1. Best regards, Andreas
On Sun, Nov 13, 2016 at 09:29:11PM +0100, Andreas Cadhalpun wrote: > It causes division by zero crashes. > > Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > --- > libavcodec/aacsbr_fixed.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c > index b26314a..d2a7027 100644 > --- a/libavcodec/aacsbr_fixed.c > +++ b/libavcodec/aacsbr_fixed.c > @@ -429,6 +429,10 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, > av_add_sf(FLOAT_1, sbr->e_curr[e][m]), > av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); > } > + if (sbr->gain[e][m].mant == 0) { > + sbr->gain[e][m] = FLOAT_1; > + sbr->gain[e][m].exp = MIN_EXP; > + } Why is this not not needed for the float code ? is there a shortcomming in the SoftFloat code ? [...]
On 23.11.2016 03:22, Michael Niedermayer wrote: > On Sun, Nov 13, 2016 at 09:29:11PM +0100, Andreas Cadhalpun wrote: >> It causes division by zero crashes. >> >> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> >> --- >> libavcodec/aacsbr_fixed.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c >> index b26314a..d2a7027 100644 >> --- a/libavcodec/aacsbr_fixed.c >> +++ b/libavcodec/aacsbr_fixed.c >> @@ -429,6 +429,10 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, >> av_add_sf(FLOAT_1, sbr->e_curr[e][m]), >> av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); >> } >> + if (sbr->gain[e][m].mant == 0) { >> + sbr->gain[e][m] = FLOAT_1; >> + sbr->gain[e][m].exp = MIN_EXP; >> + } > > Why is this not not needed for the float code ? Because float can represent smaller absolute values than normalized SoftFloat. > is there a shortcomming in the SoftFloat code ? In a way, because the SoftFloat gets normalized, e.g.: * float: 2.16840434e-19 * 2.77555756e-17 / 10337.5293 = 5.82201677e-40 * SoftFloat: av_div_sf(av_mul_sf({mant = 536870912, exp = -61}, {mant = 536870912, exp = -54}), {mant = 677439305, exp = 14}) = {mant = 850858499, exp = -130} = FLOAT_0 Best regards, Andreas
On Thu, Nov 24, 2016 at 01:15:54AM +0100, Andreas Cadhalpun wrote: > On 23.11.2016 03:22, Michael Niedermayer wrote: > > On Sun, Nov 13, 2016 at 09:29:11PM +0100, Andreas Cadhalpun wrote: > >> It causes division by zero crashes. > >> > >> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> > >> --- > >> libavcodec/aacsbr_fixed.c | 4 ++++ > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c > >> index b26314a..d2a7027 100644 > >> --- a/libavcodec/aacsbr_fixed.c > >> +++ b/libavcodec/aacsbr_fixed.c > >> @@ -429,6 +429,10 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, > >> av_add_sf(FLOAT_1, sbr->e_curr[e][m]), > >> av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); > >> } > >> + if (sbr->gain[e][m].mant == 0) { > >> + sbr->gain[e][m] = FLOAT_1; > >> + sbr->gain[e][m].exp = MIN_EXP; > >> + } > > > > Why is this not not needed for the float code ? > > Because float can represent smaller absolute values than normalized SoftFloat. > > > is there a shortcomming in the SoftFloat code ? > > In a way, because the SoftFloat gets normalized, e.g.: > * float: 2.16840434e-19 * 2.77555756e-17 / 10337.5293 = 5.82201677e-40 > * SoftFloat: av_div_sf(av_mul_sf({mant = 536870912, exp = -61}, {mant = 536870912, exp = -54}), > {mant = 677439305, exp = 14}) = {mant = 850858499, exp = -130} = FLOAT_0 hmm does increasing the limits for SoftFloats exponent solve this ? If that works and doesnt break anything it would be good to have SoftFloat cover the range float has [...]
diff --git a/libavcodec/aacsbr_fixed.c b/libavcodec/aacsbr_fixed.c index b26314a..d2a7027 100644 --- a/libavcodec/aacsbr_fixed.c +++ b/libavcodec/aacsbr_fixed.c @@ -429,6 +429,10 @@ static void sbr_gain_calc(AACContext *ac, SpectralBandReplication *sbr, av_add_sf(FLOAT_1, sbr->e_curr[e][m]), av_add_sf(FLOAT_1, sbr->q_mapped[e][m])))); } + if (sbr->gain[e][m].mant == 0) { + sbr->gain[e][m] = FLOAT_1; + sbr->gain[e][m].exp = MIN_EXP; + } } for (m = sbr->f_tablelim[k] - sbr->kx[1]; m < sbr->f_tablelim[k + 1] - sbr->kx[1]; m++) { sum[0] = av_add_sf(sum[0], sbr->e_origmapped[e][m]);
It causes division by zero crashes. Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> --- libavcodec/aacsbr_fixed.c | 4 ++++ 1 file changed, 4 insertions(+)