From 0daac647af00b7cf591d1360115a725e300ca3b2 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 12 Oct 2012 22:20:09 +0100 Subject: avstring-test: fix memory leaks Signed-off-by: Mans Rullgard --- libavutil/avstring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 9b88c0b3dd..6b3a65c7f0 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -197,10 +197,12 @@ int main(void) }; for (i=0; i < FF_ARRAY_ELEMS(strings); i++) { - const char *p= strings[i]; + const char *p = strings[i], *q; printf("|%s|", p); - printf(" -> |%s|", av_get_token(&p, ":")); + q = av_get_token(&p, ":"); + printf(" -> |%s|", q); printf(" + |%s|\n", p); + av_free(q); } } -- cgit v1.2.3 From a77f01c725296321936ef671eff1a8bd2ad96f0a Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 7 Sep 2012 12:50:43 +0100 Subject: configure: use utilities from /usr/xpg4/bin if it exists Solaris defaults to non-standard utilities (grep, sed, ...) with proper ones being in /usr/xpg4/bin. Prefixing PATH with this directory when it exists ensures we get correct variants. Signed-off-by: Mans Rullgard --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index 99a5be2f59..26cd7ea73a 100755 --- a/configure +++ b/configure @@ -54,6 +54,8 @@ if test "$E1" != 0 || test "$E2" = 0; then exit 1 fi +test -d /usr/xpg4/bin && PATH=/usr/xpg4/bin:$PATH + show_help(){ cat < Date: Thu, 11 Oct 2012 14:21:56 -0400 Subject: dca: allocate a secondary buffer for extra channels when downmixing The output AVFrame buffer only has data for the downmix channels. Fixes a segfault when decoding dca with request_channels == 2. --- libavcodec/dcadec.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index d38dff81b3..eb12eb2db9 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -32,6 +32,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/audioconvert.h" +#include "libavutil/samplefmt.h" #include "avcodec.h" #include "dsputil.h" #include "fft.h" @@ -357,6 +358,9 @@ typedef struct { DECLARE_ALIGNED(32, float, subband_samples)[DCA_BLOCKS_MAX][DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; float *samples_chanptr[DCA_PRIM_CHANNELS_MAX + 1]; + float *extra_channels[DCA_PRIM_CHANNELS_MAX + 1]; + uint8_t *extra_channels_buffer; + unsigned int extra_channels_buffer_size; uint8_t dca_buffer[DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE + DCA_BUFFER_PADDING_SIZE]; int dca_buffer_size; ///< how much data is in the dca_buffer @@ -1656,7 +1660,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, int i, ret; float **samples_flt; DCAContext *s = avctx->priv_data; - int channels; + int channels, full_channels; int core_ss_end; @@ -1790,7 +1794,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, avctx->profile = s->profile; - channels = s->prim_channels + !!s->lfe; + full_channels = channels = s->prim_channels + !!s->lfe; if (s->amode < 16) { avctx->channel_layout = dca_core_channel_layout[s->amode]; @@ -1852,12 +1856,35 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, } samples_flt = (float **) s->frame.extended_data; + /* allocate buffer for extra channels if downmixing */ + if (avctx->channels < full_channels) { + ret = av_samples_get_buffer_size(NULL, full_channels - channels, + s->frame.nb_samples, + avctx->sample_fmt, 0); + if (ret < 0) + return ret; + + av_fast_malloc(&s->extra_channels_buffer, + &s->extra_channels_buffer_size, ret); + if (!s->extra_channels_buffer) + return AVERROR(ENOMEM); + + ret = av_samples_fill_arrays((uint8_t **)s->extra_channels, NULL, + s->extra_channels_buffer, + full_channels - channels, + s->frame.nb_samples, avctx->sample_fmt, 0); + if (ret < 0) + return ret; + } + /* filter to get final output */ for (i = 0; i < (s->sample_blocks / 8); i++) { int ch; for (ch = 0; ch < channels; ch++) s->samples_chanptr[ch] = samples_flt[ch] + i * 256; + for (; ch < full_channels; ch++) + s->samples_chanptr[ch] = s->extra_channels[ch - channels] + i * 256; dca_filter_channels(s, i); @@ -1922,6 +1949,7 @@ static av_cold int dca_decode_end(AVCodecContext *avctx) { DCAContext *s = avctx->priv_data; ff_mdct_end(&s->imdct); + av_freep(&s->extra_channels_buffer); return 0; } -- cgit v1.2.3 From f5962229bfcb14c2879e69ccdf7f1a4934168609 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 7 Oct 2012 23:55:32 -0400 Subject: avplay: use audio parameters from the decoded frame instead of AVCodecContext --- avplay.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/avplay.c b/avplay.c index 597b23c651..5966109922 100644 --- a/avplay.c +++ b/avplay.c @@ -1905,13 +1905,13 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) } data_size = av_samples_get_buffer_size(NULL, dec->channels, is->frame->nb_samples, - dec->sample_fmt, 1); + is->frame->format, 1); - audio_resample = dec->sample_fmt != is->sdl_sample_fmt || - dec->channel_layout != is->sdl_channel_layout; + audio_resample = is->frame->format != is->sdl_sample_fmt || + is->frame->channel_layout != is->sdl_channel_layout; - resample_changed = dec->sample_fmt != is->resample_sample_fmt || - dec->channel_layout != is->resample_channel_layout; + resample_changed = is->frame->format != is->resample_sample_fmt || + is->frame->channel_layout != is->resample_channel_layout; if ((!is->avr && audio_resample) || resample_changed) { int ret; @@ -1925,9 +1925,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) } } if (audio_resample) { - av_opt_set_int(is->avr, "in_channel_layout", dec->channel_layout, 0); - av_opt_set_int(is->avr, "in_sample_fmt", dec->sample_fmt, 0); - av_opt_set_int(is->avr, "in_sample_rate", dec->sample_rate, 0); + av_opt_set_int(is->avr, "in_channel_layout", is->frame->channel_layout, 0); + av_opt_set_int(is->avr, "in_sample_fmt", is->frame->format, 0); + av_opt_set_int(is->avr, "in_sample_rate", is->frame->sample_rate, 0); av_opt_set_int(is->avr, "out_channel_layout", is->sdl_channel_layout, 0); av_opt_set_int(is->avr, "out_sample_fmt", is->sdl_sample_fmt, 0); av_opt_set_int(is->avr, "out_sample_rate", dec->sample_rate, 0); @@ -1937,8 +1937,8 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) break; } } - is->resample_sample_fmt = dec->sample_fmt; - is->resample_channel_layout = dec->channel_layout; + is->resample_sample_fmt = is->frame->format; + is->resample_channel_layout = is->frame->channel_layout; } if (audio_resample) { -- cgit v1.2.3