diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-10-13 16:39:42 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-10-13 16:39:42 +0200 |
commit | 15ef1cfe6431179fb1cd5707b360a7d6d6bdb9d9 (patch) | |
tree | 9a5c513d65689913fbbe2abb5be0e7ba6d6afa5e | |
parent | 6571833d1a54a0be996481970de09487aa5a55d9 (diff) | |
parent | f5962229bfcb14c2879e69ccdf7f1a4934168609 (diff) | |
download | ffmpeg-15ef1cfe6431179fb1cd5707b360a7d6d6bdb9d9.tar.gz |
Merge commit 'f5962229bfcb14c2879e69ccdf7f1a4934168609'
* commit 'f5962229bfcb14c2879e69ccdf7f1a4934168609':
avplay: use audio parameters from the decoded frame instead of AVCodecContext
dca: allocate a secondary buffer for extra channels when downmixing
configure: use utilities from /usr/xpg4/bin if it exists
avstring-test: fix memory leaks
Conflicts:
ffplay.c
libavcodec/dcadec.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | libavcodec/dcadec.c | 32 | ||||
-rw-r--r-- | libavutil/avstring.c | 6 |
3 files changed, 36 insertions, 4 deletions
@@ -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 <<EOF Usage: configure [options] diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 4d5e1152f2..42f1eed6f0 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" @@ -420,6 +421,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 @@ -2070,7 +2074,7 @@ static int dca_decode_frame(AVCodecContext *avctx, void *data, float *dst_chan; DCAContext *s = avctx->priv_data; int core_ss_end; - int channels; + int channels, full_channels; float scale; int achan; int chset; @@ -2211,7 +2215,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 we have XXCH then the channel layout is managed differently */ /* note that XLL will also have another way to do things */ @@ -2340,12 +2344,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); @@ -2457,6 +2484,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; } diff --git a/libavutil/avstring.c b/libavutil/avstring.c index 8b258a4971..73ab7aad1b 100644 --- a/libavutil/avstring.c +++ b/libavutil/avstring.c @@ -252,10 +252,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); } } |