Message ID | 20200904172026.28217-4-andreas.rheinhardt@gmail.com |
---|---|
State | Accepted |
Commit | 2777bae7f2fbb96843bc2d12c9190a12ffdfef55 |
Headers | show |
Series | [FFmpeg-devel,1/6] avcodec/bink: Fix memleak upon init failure | expand |
On 9/4/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote: > Move it to the context instead. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> > --- > libavcodec/binkaudio.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > Wow, nice catch, LGTM. > diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c > index 012190a955..f17164da91 100644 > --- a/libavcodec/binkaudio.c > +++ b/libavcodec/binkaudio.c > @@ -40,8 +40,6 @@ > #include "rdft.h" > #include "wma_freqs.h" > > -static float quant_table[96]; > - > #define MAX_CHANNELS 2 > #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11) > > @@ -58,6 +56,7 @@ typedef struct BinkAudioContext { > float root; > DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE]; > float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs > from previous audio block > + float quant_table[96]; > AVPacket *pkt; > union { > RDFTContext rdft; > @@ -116,7 +115,7 @@ static av_cold int decode_init(AVCodecContext *avctx) > s->root = s->frame_len / (sqrt(s->frame_len) * 32768.0); > for (i = 0; i < 96; i++) { > /* constant is result of 0.066399999/log10(M_E) */ > - quant_table[i] = expf(i * 0.15289164787221953823f) * s->root; > + s->quant_table[i] = expf(i * 0.15289164787221953823f) * s->root; > } > > /* calculate number of bands */ > @@ -197,7 +196,7 @@ static int decode_block(BinkAudioContext *s, float > **out, int use_dct) > return AVERROR_INVALIDDATA; > for (i = 0; i < s->num_bands; i++) { > int value = get_bits(gb, 8); > - quant[i] = quant_table[FFMIN(value, 95)]; > + quant[i] = s->quant_table[FFMIN(value, 95)]; > } > > k = 0; > -- > 2.20.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavcodec/binkaudio.c b/libavcodec/binkaudio.c index 012190a955..f17164da91 100644 --- a/libavcodec/binkaudio.c +++ b/libavcodec/binkaudio.c @@ -40,8 +40,6 @@ #include "rdft.h" #include "wma_freqs.h" -static float quant_table[96]; - #define MAX_CHANNELS 2 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11) @@ -58,6 +56,7 @@ typedef struct BinkAudioContext { float root; DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE]; float previous[MAX_CHANNELS][BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block + float quant_table[96]; AVPacket *pkt; union { RDFTContext rdft; @@ -116,7 +115,7 @@ static av_cold int decode_init(AVCodecContext *avctx) s->root = s->frame_len / (sqrt(s->frame_len) * 32768.0); for (i = 0; i < 96; i++) { /* constant is result of 0.066399999/log10(M_E) */ - quant_table[i] = expf(i * 0.15289164787221953823f) * s->root; + s->quant_table[i] = expf(i * 0.15289164787221953823f) * s->root; } /* calculate number of bands */ @@ -197,7 +196,7 @@ static int decode_block(BinkAudioContext *s, float **out, int use_dct) return AVERROR_INVALIDDATA; for (i = 0; i < s->num_bands; i++) { int value = get_bits(gb, 8); - quant[i] = quant_table[FFMIN(value, 95)]; + quant[i] = s->quant_table[FFMIN(value, 95)]; } k = 0;
Move it to the context instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> --- libavcodec/binkaudio.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)