From 5f2e6c0fd11f34ba7cd013a0b22d7bd0d60613b8 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Sat, 12 Mar 2011 22:17:14 +0000 Subject: [PATCH 01/10] ac3enc: NEON optimised extract_exponents Signed-off-by: Mans Rullgard --- libavcodec/arm/ac3dsp_init_arm.c | 2 ++ libavcodec/arm/ac3dsp_neon.S | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libavcodec/arm/ac3dsp_init_arm.c b/libavcodec/arm/ac3dsp_init_arm.c index 92e4a4f291..fd78e1e6a4 100644 --- a/libavcodec/arm/ac3dsp_init_arm.c +++ b/libavcodec/arm/ac3dsp_init_arm.c @@ -28,6 +28,7 @@ int ff_ac3_max_msb_abs_int16_neon(const int16_t *src, int len); void ff_ac3_lshift_int16_neon(int16_t *src, unsigned len, unsigned shift); void ff_ac3_rshift_int32_neon(int32_t *src, unsigned len, unsigned shift); void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len); +void ff_ac3_extract_exponents_neon(uint8_t *exp, int32_t *coef, int nb_coefs); void ff_ac3_bit_alloc_calc_bap_armv6(int16_t *mask, int16_t *psd, int start, int end, @@ -50,5 +51,6 @@ av_cold void ff_ac3dsp_init_arm(AC3DSPContext *c, int bit_exact) c->ac3_lshift_int16 = ff_ac3_lshift_int16_neon; c->ac3_rshift_int32 = ff_ac3_rshift_int32_neon; c->float_to_fixed24 = ff_float_to_fixed24_neon; + c->extract_exponents = ff_ac3_extract_exponents_neon; } } diff --git a/libavcodec/arm/ac3dsp_neon.S b/libavcodec/arm/ac3dsp_neon.S index d33d978d7c..946b39f25b 100644 --- a/libavcodec/arm/ac3dsp_neon.S +++ b/libavcodec/arm/ac3dsp_neon.S @@ -92,3 +92,23 @@ function ff_float_to_fixed24_neon, export=1 bgt 1b bx lr endfunc + +function ff_ac3_extract_exponents_neon, export=1 + vmov.i32 q14, #24 + vmov.i32 q15, #8 +1: + vld1.32 {q0}, [r1,:128] + vabs.s32 q1, q0 + vclz.i32 q3, q1 + vsub.i32 q3, q3, q15 + vcge.s32 q2, q3, q14 + vbit q3, q14, q2 + vbic q0, q0, q2 + vmovn.i32 d6, q3 + vmovn.i16 d6, q3 + vst1.32 {q0}, [r1,:128]! + vst1.32 {d6[0]}, [r0,:32]! + subs r2, r2, #4 + bgt 1b + bx lr +endfunc From fa104e14abc1361762cb2451cc83072e4d2a5d52 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 4 Apr 2011 19:46:19 +0200 Subject: [PATCH 02/10] avio: deprecate av_url_read_pause It's not used anywhere internally. Salvage its documentation for ffio_read_pause. --- libavformat/avio.c | 2 ++ libavformat/avio.h | 8 +------- libavformat/avio_internal.h | 5 +++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 24cec8fde3..97f0e25a66 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -388,12 +388,14 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) url_interrupt_cb = interrupt_cb; } +#if FF_API_OLD_AVIO int av_url_read_pause(URLContext *h, int pause) { if (!h->prot->url_read_pause) return AVERROR(ENOSYS); return h->prot->url_read_pause(h, pause); } +#endif int64_t av_url_read_seek(URLContext *h, int stream_index, int64_t timestamp, int flags) diff --git a/libavformat/avio.h b/libavformat/avio.h index 427aa8c938..6ca472cdec 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -114,6 +114,7 @@ attribute_deprecated int64_t url_filesize(URLContext *h); attribute_deprecated int url_get_file_handle(URLContext *h); attribute_deprecated int url_get_max_packet_size(URLContext *h); attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size); +attribute_deprecated int av_url_read_pause(URLContext *h, int pause); #endif /** @@ -135,13 +136,6 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); #endif -/** - * Pause and resume playing - only meaningful if using a network streaming - * protocol (e.g. MMS). - * @param pause 1 for pause, 0 for resume - */ -int av_url_read_pause(URLContext *h, int pause); - /** * Seek to a given timestamp relative to some component stream. * Only meaningful if using a network streaming protocol (e.g. MMS.). diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index b0f96cfa53..db3b30855b 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -66,6 +66,11 @@ uint64_t ffio_read_varlen(AVIOContext *bc); /** @warning must be called before any I/O */ int ffio_set_buf_size(AVIOContext *s, int buf_size); +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ int ffio_read_pause(AVIOContext *h, int pause); int64_t ffio_read_seek (AVIOContext *h, int stream_index, int64_t timestamp, int flags); From 1305d93c42946ef524c1cdc927a7e66eec510005 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 4 Apr 2011 19:48:31 +0200 Subject: [PATCH 03/10] avio: deprecate av_url_read_seek It's not used anywhere internally. Salvage its documentation for ffio_read_seek. --- libavformat/avio.c | 2 +- libavformat/avio.h | 21 ++------------------- libavformat/avio_internal.h | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 97f0e25a66..976499ff14 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -395,7 +395,6 @@ int av_url_read_pause(URLContext *h, int pause) return AVERROR(ENOSYS); return h->prot->url_read_pause(h, pause); } -#endif int64_t av_url_read_seek(URLContext *h, int stream_index, int64_t timestamp, int flags) @@ -404,3 +403,4 @@ int64_t av_url_read_seek(URLContext *h, return AVERROR(ENOSYS); return h->prot->url_read_seek(h, stream_index, timestamp, flags); } +#endif diff --git a/libavformat/avio.h b/libavformat/avio.h index 6ca472cdec..08453731df 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -115,6 +115,8 @@ attribute_deprecated int url_get_file_handle(URLContext *h); attribute_deprecated int url_get_max_packet_size(URLContext *h); attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size); attribute_deprecated int av_url_read_pause(URLContext *h, int pause); +attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index, + int64_t timestamp, int flags); #endif /** @@ -136,25 +138,6 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); #endif -/** - * Seek to a given timestamp relative to some component stream. - * Only meaningful if using a network streaming protocol (e.g. MMS.). - * @param stream_index The stream index that the timestamp is relative to. - * If stream_index is (-1) the timestamp should be in AV_TIME_BASE - * units from the beginning of the presentation. - * If a stream_index >= 0 is used and the protocol does not support - * seeking based on component streams, the call will fail with ENOTSUP. - * @param timestamp timestamp in AVStream.time_base units - * or if there is no stream specified then in AV_TIME_BASE units. - * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE - * and AVSEEK_FLAG_ANY. The protocol may silently ignore - * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will - * fail with ENOTSUP if used and not supported. - * @return >= 0 on success - * @see AVInputFormat::read_seek - */ -int64_t av_url_read_seek(URLContext *h, int stream_index, - int64_t timestamp, int flags); #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index db3b30855b..5ef4cca7dd 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -72,6 +72,23 @@ int ffio_set_buf_size(AVIOContext *s, int buf_size); * @param pause 1 for pause, 0 for resume */ int ffio_read_pause(AVIOContext *h, int pause); +/** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + */ int64_t ffio_read_seek (AVIOContext *h, int stream_index, int64_t timestamp, int flags); From b84048479888739e0aa8d9e534c49a3ab0e02252 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 4 Apr 2011 19:55:07 +0200 Subject: [PATCH 04/10] avio: make URL_PROTOCOL_FLAG_NESTED_SCHEME internal --- libavformat/avio.h | 2 +- libavformat/url.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/avio.h b/libavformat/avio.h index 08453731df..5a535f7973 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -136,10 +136,10 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); #if FF_API_OLD_AVIO /* not implemented */ attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout); -#endif #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ +#endif typedef struct URLProtocol { const char *name; diff --git a/libavformat/url.h b/libavformat/url.h index eea9678ddc..72c19b62ad 100644 --- a/libavformat/url.h +++ b/libavformat/url.h @@ -26,6 +26,11 @@ #define AVFORMAT_URL_H #include "avio.h" +#include "libavformat/version.h" + +#if !FF_API_OLD_AVIO +#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */ +#endif /** * Create a URLContext for accessing to the resource indicated by From 14cf0fd2f586471fff4ee379739a5734f568af11 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Mon, 4 Apr 2011 16:07:23 -0700 Subject: [PATCH 05/10] Add silence support for AV_SAMPLE_FMT_U8. Signed-off-by: Anton Khirnov --- ffmpeg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ffmpeg.c b/ffmpeg.c index 5e50db3389..1f7b8879d0 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1390,6 +1390,14 @@ static void print_report(AVFormatContext **output_files, } } +static void generate_silence(uint8_t* buf, enum AVSampleFormat sample_fmt, size_t size) +{ + int fill_char = 0x00; + if (sample_fmt == AV_SAMPLE_FMT_U8) + fill_char = 0x80; + memset(buf, fill_char, size); +} + /* pkt = NULL means EOF (needed to flush decoder buffers) */ static int output_packet(AVInputStream *ist, int ist_index, AVOutputStream **ost_table, int nb_ostreams, @@ -1732,7 +1740,7 @@ static int output_packet(AVInputStream *ist, int ist_index, int frame_bytes = enc->frame_size*osize*enc->channels; if (allocated_audio_buf_size < frame_bytes) ffmpeg_exit(1); - memset(audio_buf+fifo_bytes, 0, frame_bytes - fifo_bytes); + generate_silence(audio_buf+fifo_bytes, enc->sample_fmt, frame_bytes - fifo_bytes); } ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, (short *)audio_buf); From f4f05c459c41e8c43d3642a96001c69bc7173544 Mon Sep 17 00:00:00 2001 From: Konstantin Pavlov Date: Tue, 5 Apr 2011 00:49:34 +0400 Subject: [PATCH 06/10] configure: tell user if libva is enabled like the rest of external libs. Signed-off-by: Anton Khirnov --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index e86f193738..92a809fb69 100755 --- a/configure +++ b/configure @@ -3131,6 +3131,7 @@ echo "librtmp enabled ${librtmp-no}" echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libtheora enabled ${libtheora-no}" +echo "libva enabled ${vaapi-no}" echo "libvorbis enabled ${libvorbis-no}" echo "libvpx enabled ${libvpx-no}" echo "libx264 enabled ${libx264-no}" From d6f66edd65992c1275f8e4271be212e1a4808425 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Tue, 5 Apr 2011 12:21:50 +0200 Subject: [PATCH 07/10] Revert "aac_latm_dec: use aac context and aac m4ac" This reverts commit 36864ac3540445c513484017aa9927e942fac24a since it breaks LATM decoding in ffplay. --- libavcodec/aacdec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index 05bd7ed3d3..3ce0dce491 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -2250,6 +2250,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb) { AVCodecContext *avctx = latmctx->aac_ctx.avctx; + MPEG4AudioConfig m4ac; int config_start_bit = get_bits_count(gb); int bits_consumed, esize; @@ -2259,8 +2260,7 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx, return AVERROR_INVALIDDATA; } else { bits_consumed = - decode_audio_specific_config(&latmctx->aac_ctx, avctx, - &latmctx->aac_ctx.m4ac, + decode_audio_specific_config(NULL, avctx, &m4ac, gb->buffer + (config_start_bit / 8), get_bits_left(gb) / 8); From ba9ef8d04ecd009036b7c380e71bac081c56c53e Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Tue, 29 Mar 2011 17:18:21 -0400 Subject: [PATCH 08/10] Remove unnecessary parameter from ff_thread_init() and fix behavior thread_count passed to ff_thread_init() is only used to set AVCodecContext. thread_count, and can be removed. Instead move it to the legacy implementation of avcodec_thread_init(). This also fixes the problem that calling avcodec_thread_init() with pthreads enabled did not set it since ff1efc524cb3c60f2f746e3b4550bb1a86c65316. Signed-off-by: Janne Grunau --- libavcodec/pthread.c | 2 +- libavcodec/thread.h | 2 +- libavcodec/utils.c | 8 ++++---- libavcodec/w32thread.c | 9 ++++----- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c index c40fde3a02..70845f0ba0 100644 --- a/libavcodec/pthread.c +++ b/libavcodec/pthread.c @@ -882,7 +882,7 @@ static void validate_thread_parameters(AVCodecContext *avctx) } } -int ff_thread_init(AVCodecContext *avctx, int thread_count) +int ff_thread_init(AVCodecContext *avctx) { if (avctx->thread_opaque) { av_log(avctx, AV_LOG_ERROR, "avcodec_thread_init is ignored after avcodec_open\n"); diff --git a/libavcodec/thread.h b/libavcodec/thread.h index e63c10a5e4..401c4d25a8 100644 --- a/libavcodec/thread.h +++ b/libavcodec/thread.h @@ -108,7 +108,7 @@ int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f); */ void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f); -int ff_thread_init(AVCodecContext *s, int thread_count); +int ff_thread_init(AVCodecContext *s); void ff_thread_free(AVCodecContext *s); #endif /* AVCODEC_THREAD_H */ diff --git a/libavcodec/utils.c b/libavcodec/utils.c index bf6baf4e78..12561d0e32 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -539,7 +539,7 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec) avctx->frame_number = 0; if (HAVE_THREADS && !avctx->thread_opaque) { - ret = ff_thread_init(avctx, avctx->thread_count); + ret = ff_thread_init(avctx); if (ret < 0) { goto free_and_end; } @@ -1147,8 +1147,7 @@ int av_get_bits_per_sample_format(enum AVSampleFormat sample_fmt) { #endif #if !HAVE_THREADS -int ff_thread_init(AVCodecContext *s, int thread_count){ - s->thread_count = thread_count; +int ff_thread_init(AVCodecContext *s){ return -1; } #endif @@ -1291,7 +1290,8 @@ void ff_thread_await_progress(AVFrame *f, int progress, int field) int avcodec_thread_init(AVCodecContext *s, int thread_count) { - return ff_thread_init(s, thread_count); + s->thread_count = thread_count; + return ff_thread_init(s); } void avcodec_thread_free(AVCodecContext *s) diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c index 27a928e855..023be0e663 100644 --- a/libavcodec/w32thread.c +++ b/libavcodec/w32thread.c @@ -125,7 +125,7 @@ static int avcodec_thread_execute2(AVCodecContext *s, int (*func)(AVCodecContext avcodec_thread_execute(s, NULL, arg, ret, count, 0); } -int ff_thread_init(AVCodecContext *s, int thread_count){ +int ff_thread_init(AVCodecContext *s){ int i; ThreadContext *c; uint32_t threadid; @@ -135,14 +135,13 @@ int ff_thread_init(AVCodecContext *s, int thread_count){ return 0; } - s->thread_count= thread_count; s->active_thread_type= FF_THREAD_SLICE; - if (thread_count <= 1) + if (s->thread_count <= 1) return 0; assert(!s->thread_opaque); - c= av_mallocz(sizeof(ThreadContext)*thread_count); + c= av_mallocz(sizeof(ThreadContext)*s->thread_count); s->thread_opaque= c; if(!(c[0].work_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL))) goto fail; @@ -151,7 +150,7 @@ int ff_thread_init(AVCodecContext *s, int thread_count){ if(!(c[0].done_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL))) goto fail; - for(i=0; ithread_count; i++){ //printf("init semaphors %d\n", i); fflush(stdout); c[i].avctx= s; c[i].work_sem = c[0].work_sem; From 668438a31ef654a2836992879f9bcd23f4d3421e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 5 Apr 2011 19:04:28 +0200 Subject: [PATCH 09/10] avio: always compile dyn_buf functions Fixes build with --disable-muxers --disable-network. Thanks to Hendrik Leppkes for noticing. --- libavformat/aviobuf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index dd250277f2..49aaf205d6 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -1040,9 +1040,6 @@ int64_t ffio_read_seek(AVIOContext *s, int stream_index, return ret; } -/* avio_open_dyn_buf and avio_close_dyn_buf are used in rtp.c to send a response - * back to the server even if CONFIG_MUXERS is false. */ -#if CONFIG_MUXERS || CONFIG_NETWORK /* buffer handling */ #if FF_API_OLD_AVIO int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags) @@ -1189,4 +1186,3 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) av_free(s); return size - padding; } -#endif /* CONFIG_MUXERS || CONFIG_NETWORK */ From 5371803dd5d9f7bbc62d68274084d25f10a8dc61 Mon Sep 17 00:00:00 2001 From: Nathan Caldwell Date: Tue, 5 Apr 2011 01:05:22 -0600 Subject: [PATCH 10/10] psymodel: extend API to include PE and bit allocation. Signed-off-by: Janne Grunau --- libavcodec/psymodel.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/psymodel.h b/libavcodec/psymodel.h index 296d1ab9e9..91eb9aeab9 100644 --- a/libavcodec/psymodel.h +++ b/libavcodec/psymodel.h @@ -26,6 +26,8 @@ /** maximum possible number of bands */ #define PSY_MAX_BANDS 128 +/** maximum number of channels */ +#define PSY_MAX_CHANS 20 /** * single band psychoacoustic information @@ -62,6 +64,13 @@ typedef struct FFPsyContext { int *num_bands; ///< number of scalefactor bands for possible frame sizes int num_lens; ///< number of scalefactor band sets + float pe[PSY_MAX_CHANS]; ///< total PE for each channel in the frame + + struct { + int size; ///< size of the bitresevoir in bits + int bits; ///< number of bits used in the bitresevoir + } bitres; + void* model_priv_data; ///< psychoacoustic model implementation private data } FFPsyContext;