From 8441909f49d1cb172c714b4a6b9527aefb82b3fe Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sun, 14 Oct 2012 14:31:47 -0400 Subject: lavc: update documentation for AVFrame.extended_data --- libavcodec/avcodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 51270e6527..cda6703167 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -990,7 +990,7 @@ typedef struct AVFrame { * extended_data must be used by the decoder in order to access all * channels. * - * encoding: unused + * encoding: set by user * decoding: set by AVCodecContext.get_buffer() */ uint8_t **extended_data; -- cgit v1.2.3 From 977eb7d567f6e3f7562a2c5682d346372ba105b4 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 28 Aug 2012 14:02:41 -0400 Subject: shorten: use planar sample format --- libavcodec/shorten.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index fb48070eb6..1664a907ae 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -112,7 +112,7 @@ static av_cold int shorten_decode_init(AVCodecContext * avctx) { ShortenContext *s = avctx->priv_data; s->avctx = avctx; - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame; @@ -259,13 +259,16 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header, return 0; } -static void interleave_buffer(int16_t *samples, int nchan, int blocksize, - int32_t **buffer) +static void output_buffer(int16_t **samples, int nchan, int blocksize, + int32_t **buffer) { - int i, chan; - for (i=0; iframe.data[0], s->channels, - s->blocksize, s->decoded); + output_buffer((int16_t **)s->frame.extended_data, s->channels, + s->blocksize, s->decoded); *got_frame_ptr = 1; *(AVFrame *)data = s->frame; @@ -637,4 +640,6 @@ AVCodec ff_shorten_decoder = { .decode = shorten_decode_frame, .capabilities = CODEC_CAP_DELAY | CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Shorten"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_NONE }, }; -- cgit v1.2.3 From 7ebfe5b44a55d7f2c510e6aaeaf767319c786b60 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 28 Aug 2012 23:12:49 -0400 Subject: wmadec: use float planar sample format output --- libavcodec/wmadec.c | 65 +++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 37 deletions(-) diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c index 79401e21b6..bbb840212e 100644 --- a/libavcodec/wmadec.c +++ b/libavcodec/wmadec.c @@ -48,20 +48,6 @@ static void wma_lsp_to_curve_init(WMACodecContext *s, int frame_len); #ifdef TRACE -static void dump_shorts(WMACodecContext *s, const char *name, const short *tab, int n) -{ - int i; - - tprintf(s->avctx, "%s[%d]:\n", name, n); - for(i=0;iavctx, "%4d: ", i); - tprintf(s->avctx, " %5d.0", tab[i]); - if ((i & 7) == 7) - tprintf(s->avctx, "\n"); - } -} - static void dump_floats(WMACodecContext *s, const char *name, int prec, const float *tab, int n) { int i; @@ -105,7 +91,7 @@ static int wma_decode_init(AVCodecContext * avctx) /* init MDCT */ for(i = 0; i < s->nb_block_sizes; i++) - ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0); + ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0); if (s->use_noise_coding) { init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits), @@ -121,7 +107,7 @@ static int wma_decode_init(AVCodecContext * avctx) wma_lsp_to_curve_init(s, s->frame_len); } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avcodec_get_frame_defaults(&s->frame); avctx->coded_frame = &s->frame; @@ -762,10 +748,10 @@ next: } /* decode a frame of frame_len samples */ -static int wma_decode_frame(WMACodecContext *s, int16_t *samples) +static int wma_decode_frame(WMACodecContext *s, float **samples, + int samples_offset) { - int ret, n, ch, incr; - const float *output[MAX_CHANNELS]; + int ret, ch; #ifdef TRACE tprintf(s->avctx, "***decode_frame: %d size=%d\n", s->frame_count++, s->frame_len); @@ -782,20 +768,19 @@ static int wma_decode_frame(WMACodecContext *s, int16_t *samples) break; } - /* convert frame to integer */ - n = s->frame_len; - incr = s->nb_channels; - for (ch = 0; ch < MAX_CHANNELS; ch++) - output[ch] = s->frame_out[ch]; - s->fmt_conv.float_to_int16_interleave(samples, output, n, incr); - for (ch = 0; ch < incr; ch++) { + for (ch = 0; ch < s->nb_channels; ch++) { + /* copy current block to output */ + memcpy(samples[ch] + samples_offset, s->frame_out[ch], + s->frame_len * sizeof(*s->frame_out[ch])); /* prepare for next block */ - memmove(&s->frame_out[ch][0], &s->frame_out[ch][n], n * sizeof(float)); - } + memmove(&s->frame_out[ch][0], &s->frame_out[ch][s->frame_len], + s->frame_len * sizeof(*s->frame_out[ch])); #ifdef TRACE - dump_shorts(s, "samples", samples, n * s->nb_channels); + dump_floats(s, "samples", 6, samples[ch] + samples_offset, s->frame_len); #endif + } + return 0; } @@ -807,7 +792,8 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, WMACodecContext *s = avctx->priv_data; int nb_frames, bit_offset, i, pos, len, ret; uint8_t *q; - int16_t *samples; + float **samples; + int samples_offset; tprintf(avctx, "***decode_superframe:\n"); @@ -839,7 +825,8 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } - samples = (int16_t *)s->frame.data[0]; + samples = (float **)s->frame.extended_data; + samples_offset = 0; if (s->use_bit_reservoir) { bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); @@ -873,9 +860,9 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, skip_bits(&s->gb, s->last_bitoffset); /* this frame is stored in the last superframe and in the current one */ - if (wma_decode_frame(s, samples) < 0) + if (wma_decode_frame(s, samples, samples_offset) < 0) goto fail; - samples += s->nb_channels * s->frame_len; + samples_offset += s->frame_len; nb_frames--; } @@ -890,9 +877,9 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, s->reset_block_lengths = 1; for(i=0;inb_channels * s->frame_len; + samples_offset += s->frame_len; } /* we copy the end of the frame in the last frame buffer */ @@ -908,9 +895,9 @@ static int wma_decode_superframe(AVCodecContext *avctx, void *data, memcpy(s->last_superframe, buf + pos, len); } else { /* single frame decode */ - if (wma_decode_frame(s, samples) < 0) + if (wma_decode_frame(s, samples, samples_offset) < 0) goto fail; - samples += s->nb_channels * s->frame_len; + samples_offset += s->frame_len; } av_dlog(s->avctx, "%d %d %d %d outbytes:%td eaten:%d\n", @@ -946,6 +933,8 @@ AVCodec ff_wmav1_decoder = { .flush = flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 1"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; AVCodec ff_wmav2_decoder = { @@ -959,4 +948,6 @@ AVCodec ff_wmav2_decoder = { .flush = flush, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 2"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; -- cgit v1.2.3 From 2725ce7c7c341b174010f0fe3e00a7199341dfc9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 25 Aug 2012 19:09:40 -0400 Subject: wmalossless: output in planar sample format --- libavcodec/wmalosslessdec.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libavcodec/wmalosslessdec.c b/libavcodec/wmalosslessdec.c index df025282ae..2d8754f14f 100644 --- a/libavcodec/wmalosslessdec.c +++ b/libavcodec/wmalosslessdec.c @@ -186,9 +186,9 @@ static av_cold int decode_init(AVCodecContext *avctx) channel_mask = AV_RL32(edata_ptr + 2); s->bits_per_sample = AV_RL16(edata_ptr); if (s->bits_per_sample == 16) - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_S16P; else if (s->bits_per_sample == 24) { - avctx->sample_fmt = AV_SAMPLE_FMT_S32; + avctx->sample_fmt = AV_SAMPLE_FMT_S32P; av_log_missing_feature(avctx, "bit-depth higher than 16", 0); return AVERROR_PATCHWELCOME; } else { @@ -984,11 +984,9 @@ static int decode_subframe(WmallDecodeCtx *s) for (j = 0; j < subframe_len; j++) { if (s->bits_per_sample == 16) { - *s->samples_16[c] = (int16_t) s->channel_residues[c][j] << padding_zeroes; - s->samples_16[c] += s->num_channels; + *s->samples_16[c]++ = (int16_t) s->channel_residues[c][j] << padding_zeroes; } else { - *s->samples_32[c] = s->channel_residues[c][j] << padding_zeroes; - s->samples_32[c] += s->num_channels; + *s->samples_32[c]++ = s->channel_residues[c][j] << padding_zeroes; } } } @@ -1025,8 +1023,8 @@ static int decode_frame(WmallDecodeCtx *s) return ret; } for (i = 0; i < s->num_channels; i++) { - s->samples_16[i] = (int16_t *)s->frame.data[0] + i; - s->samples_32[i] = (int32_t *)s->frame.data[0] + i; + s->samples_16[i] = (int16_t *)s->frame.extended_data[i]; + s->samples_32[i] = (int32_t *)s->frame.extended_data[i]; } /* get frame length */ @@ -1296,4 +1294,7 @@ AVCodec ff_wmalossless_decoder = { .flush = flush, .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1 | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio Lossless"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, + AV_SAMPLE_FMT_S32P, + AV_SAMPLE_FMT_NONE }, }; -- cgit v1.2.3 From f9d732c26448a73711b9723ef3e4122038d454ff Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 28 Aug 2012 22:49:17 -0400 Subject: wmapro: use planar sample format --- libavcodec/wmaprodec.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 50f85e2938..d172895765 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -94,7 +94,6 @@ #include "put_bits.h" #include "wmaprodata.h" #include "dsputil.h" -#include "fmtconvert.h" #include "sinewin.h" #include "wma.h" #include "wma_common.h" @@ -171,7 +170,6 @@ typedef struct WMAProDecodeCtx { AVCodecContext* avctx; ///< codec context for av_log AVFrame frame; ///< AVFrame for decoded output DSPContext dsp; ///< accelerated DSP functions - FmtConvertContext fmt_conv; uint8_t frame_data[MAX_FRAMESIZE + FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data PutBitContext pb; ///< context for filling the frame_data buffer @@ -283,10 +281,9 @@ static av_cold int decode_init(AVCodecContext *avctx) s->avctx = avctx; ff_dsputil_init(&s->dsp, avctx); - ff_fmt_convert_init(&s->fmt_conv, avctx); init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; if (avctx->extradata_size >= 18) { s->decode_flags = AV_RL16(edata_ptr+14); @@ -1303,8 +1300,6 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr) int more_frames = 0; int len = 0; int i, ret; - const float *out_ptr[WMAPRO_MAX_CHANNELS]; - float *samples; /** get frame length */ if (s->len_prefix) @@ -1377,13 +1372,11 @@ static int decode_frame(WMAProDecodeCtx *s, int *got_frame_ptr) s->packet_loss = 1; return 0; } - samples = (float *)s->frame.data[0]; - /** interleave samples and write them to the output buffer */ + /** copy samples to the output buffer */ for (i = 0; i < s->num_channels; i++) - out_ptr[i] = s->channel[i].out; - s->fmt_conv.float_interleave(samples, out_ptr, s->samples_per_frame, - s->num_channels); + memcpy(s->frame.extended_data[i], s->channel[i].out, + s->samples_per_frame * sizeof(*s->channel[i].out)); for (i = 0; i < s->num_channels; i++) { /** reuse second half of the IMDCT output for the next frame */ @@ -1636,4 +1629,6 @@ AVCodec ff_wmapro_decoder = { .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DR1, .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Professional"), + .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, + AV_SAMPLE_FMT_NONE }, }; -- cgit v1.2.3 From e98b02de5f925a76bfa70ca16388b87da804baa3 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 13 Oct 2012 02:40:48 +0000 Subject: configure: check for mprotect Signed-off-by: Mans Rullgard --- configure | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure b/configure index d8a57284c9..86526393a5 100755 --- a/configure +++ b/configure @@ -1198,6 +1198,7 @@ HAVE_LIST=" mkstemp mm_empty mmap + mprotect msvcrt nanosleep poll_h @@ -3202,6 +3203,7 @@ check_func localtime_r check_func ${malloc_prefix}memalign && enable memalign check_func mkstemp check_func mmap +check_func mprotect check_func ${malloc_prefix}posix_memalign && enable posix_memalign check_func_headers malloc.h _aligned_malloc && enable aligned_malloc check_func setrlimit -- cgit v1.2.3 From 95cd815c3663603871a1f2da95846e8f72d4ea96 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 13 Oct 2012 16:00:16 +0000 Subject: swscale: try to use mmap only if available Some systems, e.g. Minix, have sys/mman.h defining MAP_ANONYMOUS without providing (working) mmap and friends. The mmx filter generation code checks only for MAP_ANONYMOUS, not for availability of mmap itself which leads to build errors on aforementioned systems. This changes the conditional compilation to use mmap only if all the required functions are available. Signed-off-by: Mans Rullgard --- libswscale/utils.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 4001606a1b..a40dfe7c00 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1018,6 +1018,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } } +#define USE_MMAP (HAVE_MMAP && HAVE_MPROTECT && defined MAP_ANONYMOUS) + /* precalculate horizontal scaler filter coefficients */ { #if HAVE_MMXEXT_INLINE @@ -1028,7 +1030,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, c->chrMmx2FilterCodeSize = initMMX2HScaler(c->chrDstW, c->chrXInc, NULL, NULL, NULL, 4); -#ifdef MAP_ANONYMOUS +#if USE_MMAP c->lumMmx2FilterCode = mmap(NULL, c->lumMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); c->chrMmx2FilterCode = mmap(NULL, c->chrMmx2FilterCodeSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); #elif HAVE_VIRTUALALLOC @@ -1051,7 +1053,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, initMMX2HScaler(c->chrDstW, c->chrXInc, c->chrMmx2FilterCode, c->hChrFilter, c->hChrFilterPos, 4); -#ifdef MAP_ANONYMOUS +#if USE_MMAP mprotect(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize, PROT_EXEC | PROT_READ); mprotect(c->chrMmx2FilterCode, c->chrMmx2FilterCodeSize, PROT_EXEC | PROT_READ); #endif @@ -1630,7 +1632,7 @@ void sws_freeContext(SwsContext *c) av_freep(&c->hChrFilterPos); #if HAVE_MMX_INLINE -#ifdef MAP_ANONYMOUS +#if USE_MMAP if (c->lumMmx2FilterCode) munmap(c->lumMmx2FilterCode, c->lumMmx2FilterCodeSize); if (c->chrMmx2FilterCode) -- cgit v1.2.3